Commit Graph

74 Commits

Author SHA1 Message Date
Eduard Iten cc6b4488ee Fix MCUboot and app flash partitioning
- Corrected device tree overlays to prevent MCUboot and app overlap
- MCUboot now at 0x8000000 (32KB), app at 0x8008000 (96KB)
- Successfully boots MCUboot which chains to application
- Shell and reset command working properly
- Black Magic Probe flashing confirmed working for both domains
2025-07-07 16:04:29 +02:00
Eduard Iten 928a176e7c Step 2 complete: MCUboot integration with single-slot configuration
- Created sysbuild configuration for MCUboot bootloader
- Added device tree overlays for correct partition layout (32KB MCUboot, 96KB app)
- Fixed MCUboot partition addressing to use boot_partition instead of slot0_partition
- MCUboot successfully boots and chains to application
- Application runs with shell and custom reset command
- Disabled signature validation for testing purposes
2025-07-07 15:59:41 +02:00
Eduard Iten 8255b2a672 Add firmware_node app - Step 1: Shell with reset command
- Create new Zephyr app for firmware management
- Target: weact_stm32g431_core board
- Features: Shell interface with custom reset command
- Tested on Zephyr 4.1.99
- Flash usage: 55,400 bytes (42.27% of 128KB)
- RAM usage: 12,864 bytes (39.26% of 32KB)
- Black Magic Probe flash runner support
2025-07-07 13:49:03 +02:00
Eduard Iten d48281436e Fix ADC devicetree compilation error for voltage divider
- Fix voltage divider devicetree configuration to reference ADC controller directly instead of channel node
- Switch from ADC API to sensor API for voltage divider usage
- Add required sensor and voltage divider configuration options
- Remove unnecessary zephyr,user node that was causing compilation issues
- The voltage divider now properly uses sensor framework and builds successfully

Hardware setup:
- Uses ADC1 channel 1 on pin PA0
- Voltage divider with 2.2kΩ output and 3.2kΩ total resistance
- Provides voltage readings through sensor API accounting for divider ratio
2025-07-07 13:36:44 +02:00
Eduard Iten dcb73c0a25 Working DT ADC sample WITHOUT resistor divider 2025-07-07 12:32:53 +02:00
Eduard Iten 2c21f1f9cb feat: Revert ADC changes and set channel 12 for VREFINT 2025-07-06 15:27:14 +02:00
Eduard Iten a2afec52e2 fix(adc_test): correct ADC reference configuration
- Revert ADC_GAIN to ADC_GAIN_1 due to driver limitation.
- Revert ADC_REF to ADC_REF_INTERNAL due to driver limitation.
- Set zephyr,vref-mv to 3300 to match observed hardware behavior.
2025-07-06 10:24:37 +02:00
Eduard Iten 2cc258e8e2 feat(adc_test): use devicetree for adc configuration
- Use named adc channel 'multisense' from devicetree
- Enable adc calibration
2025-07-06 09:55:10 +02:00
Eduard Iten a77298b3a6 Implement VND7050AJ supply voltage reading function
- Added devicetree overlay for VND7050AJ with GPIO and ADC configuration
- Created custom devicetree binding for VND7050AJ valve controller
- Implemented valve_get_supply_voltage() function with proper pin control:
  - RST=HIGH to enable VND7050AJ
  - S0=1, S1=1 for supply voltage sensing mode
  - SEN=1 to enable MULTISENSE output
  - ADC reading on PA0 (ADC1_IN1) with 12-bit resolution
- Fixed supply voltage calculation (VCC/8 per datasheet)
- Added comprehensive debug logging for all steps
- Tested and verified ADC functionality
- Current reading: 5.1V (may be limited by hardware power supply)

Files modified:
- software/lib/valve/valve.c: Main implementation
- software/apps/slave_node/boards/weact_stm32g431_core.overlay: DT config
- software/apps/slave_node/dts/bindings/vnd7050aj-valve-controller.yaml: DT binding
- software/apps/slave_node/src/main.c: Test code
- software/apps/slave_node/prj.conf: ADC driver enablement
2025-07-04 08:54:47 +02:00
Eduard Iten 45d011952f fix(valve): Correct VND7050AJ initialization and pin configuration
- Initialize RST pin as active to keep VND7050AJ out of reset state
- Clarify S0/S1 pins as output select pins with descriptive comments
- Add initialization logging to show configured max open/close times
- Ensure proper valve controller startup sequence
2025-07-03 19:04:20 +02:00
Eduard Iten bb25134b6c feat(modbus): Implement persistent and improved reconfiguration for Modbus server
This commit enhances the Modbus server's configuration handling by:

- Loading saved baudrate and unit ID settings during initialization, ensuring persistence across reboots.
- Providing improved feedback during `modbus_reconfigure`, including logging for successful changes and informing the user when a device restart is required for changes to take effect.
- Saving new configuration settings even if immediate reinitialization fails, allowing them to be applied on the next boot.
2025-07-03 18:59:01 +02:00
Eduard Iten 9f96384aa5 fix(cdc-acm): Correct CDC ACM overlay configuration
This commit fixes an issue in the `cdc-acm.overlay` file.
2025-07-03 18:57:06 +02:00
Eduard Iten b543579393 feat(modbus): Add supply voltage register and display in tool
This commit introduces a new Modbus input register for the system's supply voltage.

- The `modbus-registers.de.md` documentation is updated to include the `SUPPLY_VOLTAGE_MV` register at address `0x00F5` within the system block.
- The `modbus_server.h` header defines the new register.
- The `modbus_server.c` implementation provides a fixed value (12300 mV) for this register.
- The `modbus_tool.py` script is updated to read and display this new supply voltage value in the UI.

This lays the groundwork for integrating actual voltage measurements in the future.
2025-07-03 18:47:48 +02:00
Eduard Iten 69cf7e9511 feat(valve): Implement GPIO control for VND7050AJ
This commit implements the real valve control using the GPIOs connected to the VND7050AJ driver.

- The `weact_stm32g431_core.overlay` is updated with a specific compatible string and a device tree label for the valve controller.
- `valve.h` is extended to include GPIO device specifications.
- `valve.c` now initializes and controls the GPIOs for opening and closing the valve, including the reset logic. The IN0 and IN1 pins are interlocked to prevent simultaneous activation. The RST pin is activated before each movement and deactivated afterward.

This replaces the previous virtual/simulated valve logic with actual hardware control.
2025-07-03 18:17:31 +02:00
Eduard Iten f6ee0a5122 feat(weact_stm32g431_core): Configure VND7050AJ driver pins in overlay
Updated the weact_stm32g431_core.overlay to define the GPIO and ADC
pin assignments for the VND7050AJ driver. This includes:
- Digital I/O pins (IN0, IN1, RST, S0, S1, SEN) configured as GPIOs.
- Analog input pin (MULTISENSE/PA0) configured for ADC1.
2025-07-03 17:39:04 +02:00
Eduard Iten 6c1ff0c4df feat(refactor): Restructure project for improved modularity and clarity
This commit introduces a major refactoring of the project structure to align
with Zephyr's recommended multi-application and library organization.

Key changes include:
- Relocation of custom modules from 'software/modules/' to 'software/lib/'.
- Introduction of a central 'software/CMakeLists.txt' to manage application
  and library subdirectories.
- Creation of new Kconfig files for 'software/' and 'software/apps/slave_node/'
  to define project-wide and application-specific configurations.
- Removal of the 'gateway' and 'stm32g431_tests' applications.
- Removal of 'shell_modbus.c' and 'shell_system.c' from 'slave_node' application's
  direct source files, indicating a shift towards library-based shell commands.
- Updates to 'software/apps/slave_node/CMakeLists.txt', 'prj.conf', and
  'boards/bluepill_f103rb.conf' to reflect the new structure and dependencies.
2025-07-03 16:58:43 +02:00
Eduard Iten 3f0d5a76c6 feat(cdc_acm): Add CDC-ACM support and remove old test applications
- Implemented CDC-ACM (USB Virtual COM Port) support for the slave_node application.
- Removed the now obsolete 'hello_world' and 'stm32g431_tests' applications.
2025-07-03 14:31:17 +02:00
Eduard Iten 10a770de59 fix(modbus_server): Implement hardcoded firmware version 0.0.1
Set firmware version to 0.0.1 in modbus_server.c for Modbus tool display.
This is a temporary solution until MCUboot integration is complete.
2025-07-03 13:43:15 +02:00
Eduard Iten 1b0519aadf Resolve merge conflict in modbus_server.c and add hardcoded firmware version. 2025-07-03 13:34:59 +02:00
Eduard Iten e429a0874d Revert "feat(slave_node): Refine Modbus UART and add CDC-ACM support"
This reverts commit 3a05c80b25.
2025-07-03 13:34:01 +02:00
Eduard Iten 3a05c80b25 feat(slave_node): Refine Modbus UART and add CDC-ACM support
- Adjusted Device Tree Overlays for bluepill_f103rb and weact_stm32g431_core
  to correctly define Modbus UART via 'modbus0' subnode with 'zephyr,modbus-serial'
  compatibility, aligning with rtu_server sample.
- Prepared modbus_server.c to use the correct Device Tree node for Modbus UART.
2025-07-03 13:18:47 +02:00
Eduard Iten 5208f1370d feat(slave_node): Support multi-board build for bluepill_f103rb and weact_stm32g431_core
Refactor slave_node application to support building for both bluepill_f103rb and
weact_stm32g431_core boards.

- Moved RTT-specific console and shell backend configurations from prj.conf
  into board-specific .conf files (bluepill_f103rb.conf).
- Configured USART2 as console/shell for weact_stm32g431_core.
- Added Device Tree Overlay for weact_stm32g431_core to enable USART1 for Modbus
  communication (PA9/PA10).
2025-07-03 10:53:21 +02:00
Eduard Iten a59e8518cc Rename hello_world app to stm32g431_tests 2025-07-03 10:02:53 +02:00
Eduard Iten 2a2890b675 Fix: hello_world prj.conf - set correct board name 2025-07-03 09:21:48 +02:00
Eduard Iten 38fd3a6aac Add hello_world Zephyr application for stm32g431_core 2025-07-03 09:15:11 +02:00
Eduard Iten c3df6565b7 Refactor fwu library into a Zephyr module 2025-07-02 21:30:15 +02:00
Eduard Iten 140d2baa24 Fix: modbus_tool.py - replace is_connected() with is_socket_open() and fix UnboundLocalError 2025-07-02 21:05:40 +02:00
Eduard Iten 711341f362 Refactor slave_node application to use Zephyr modules 2025-07-02 20:47:16 +02:00
Eduard Iten a5da0a61dd Update modbus_tool.py 2025-07-02 17:10:11 +02:00
Eduard Iten b54c73edb1 fix: handle connection loss and re-establish in modbus_tool.py 2025-07-02 10:03:23 +02:00
Eduard Iten 2418d4e218 fix: resolve build error by moving modbus register enums to header 2025-07-02 10:02:40 +02:00
Eduard Iten 2b4890f052 fix: correct modbus_tool.py update for reset command 2025-07-02 09:58:19 +02:00
Eduard Iten 85d493f24a feat: implement modbus reset command and update docs/tool 2025-07-02 09:55:42 +02:00
Eduard Iten f486d4c4ab cleanup: remove unused CMakeLists.txt and empty modbus directory 2025-07-02 09:54:01 +02:00
Eduard Iten 6cfd4b8b4d refactor: restructure slave_node into libraries 2025-07-02 09:45:22 +02:00
Eduard Iten 0088030d66 docs: replace svg logo with png version 2025-07-02 09:22:37 +02:00
Eduard Iten 4d828b41f1 docs: Add project logo to all markdown files
Added the new project logo to the header of all relevant markdown documentation files to improve brand consistency and visual appeal.
2025-07-01 23:37:30 +02:00
Eduard Iten 95f435923f feat(main): Add detailed source code documentation
Add comprehensive Doxygen-style comments to all functions, enums, and macros in `main.c`. This improves code clarity and maintainability. The Doxygen configuration itself was removed after deciding against generating a separate HTML manual, but the in-code comments provide significant value on their own.
2025-07-01 23:29:26 +02:00
Eduard Iten 33f2a15cf3 docs(slave_node): Add Doxygen comments to main.c
- Add Doxygen-compliant comments to functions, enums, and state variables in `main.c`.
- This provides a foundation for automatically generating source code documentation.
- Remove the separate, now redundant, `firmware-manual.de.md` file.
2025-07-01 22:56:30 +02:00
Eduard Iten 773027f6b0 feat(slave_node): Implement Modbus watchdog timer
- Add a fail-safe watchdog using a Zephyr kernel timer.
- The timer is reset on any successful Modbus communication.
- If the timer expires (no communication within the configured timeout), the valve is automatically closed as a safety measure.
- The watchdog is enabled by writing a non-zero value to the `WATCHDOG_TIMEOUT_S` register and disabled by writing 0.
2025-07-01 22:46:57 +02:00
Eduard Iten 461cce7a48 fix(modbus_tool): Adjust UI layout for alignment
- Shorten "Device Status" label to "Dev. Status".
- Realign the rightmost column for better readability.
2025-07-01 22:38:52 +02:00
Eduard Iten 23b88ada83 feat(modbus_tool): Add interactive file browser for firmware updates
- Implement a simple, curses-based file browser to allow selecting firmware files from the filesystem.
- The selected file path is used for the firmware update process.
- Fix a visual bug where the progress bar would not reach 100% upon completion.
- Remove a leftover  function that was causing a NameError.
2025-07-01 22:15:44 +02:00
Eduard Iten c2916662e2 feat(modbus_tool): Implement simulated firmware update
- Add a new thread to handle the firmware update process, preventing the UI from freezing.
- The UI now displays a progress bar and status messages during the update.
- The tool reads a  file and sends it to the slave in chunks.
- Add a dummy  for testing purposes.
- Fix Modbus communication issues by reducing the chunk size to a safe value (248 bytes) and sending data in smaller bursts to improve stability.
- Update the README with the new features and instructions.
2025-07-01 21:55:19 +02:00
Eduard Iten 24087f5622 fix(slave_node): Increase Modbus buffer size
- Set CONFIG_MODBUS_BUFFER_SIZE to 256 to ensure the slave can handle larger data packets sent by the client during firmware updates.
2025-07-01 21:55:01 +02:00
Eduard Iten 95fd88e93e feat(modbus_tool): Adapt UI to full register map
- Update the TUI to display all new registers from the slave, including digital I/O and system status.
- Add new menu buttons to control digital outputs and set the watchdog timer.
- Add a placeholder button for the firmware update process.
- Fix various bugs, including incorrect argument passing in Modbus calls and a module import error.
2025-07-01 21:36:28 +02:00
Eduard Iten 21797d8507 feat(slave_node): Implement full Modbus register map
- Implement all remaining Modbus registers as defined in the documentation v1.0.
- Add support for digital I/O, system status, and a simulated watchdog.
- Implement a placeholder for the firmware update mechanism, including CRC calculation for received data chunks.
- Remove the input simulation timer; digital inputs are now static and ready for real hardware.
2025-07-01 21:36:10 +02:00
Eduard Iten 6dcb11ae0c fix(modbus_tool): Improve UI stability and readability
- Refactor the curses drawing loop to be state-based, eliminating screen flicker after user input.
- Add a helper function to format uptime from seconds into a human-readable string (d/h/m/s).
2025-07-01 21:17:30 +02:00
Eduard Iten 38d6dbe95a feat(modbus_tool): Add interactive TUI and documentation
- Replace the basic command-line prompt with a full-screen, interactive TUI using the  library.
- The new UI provides a real-time, tabular status display and intuitive, button-style menu navigation.
- Implement a consistent blue background theme for better aesthetics.
- Add a detailed  with installation and usage instructions.
- Fix several bugs in the Modbus communication logic.
2025-07-01 20:59:47 +02:00
Eduard Iten b100a8acf7 feat(shell): Add commands for valve timing
- Add shell commands 'valve set_open_time' and 'valve set_close_time' to configure the virtual valve.
- Extend the 'show_config' command to display the new timing values.
- The new settings are persisted to flash storage.
2025-07-01 18:24:20 +02:00
Eduard Iten 269e9e88a1 feat(valve): Implement safe virtual valve control
- Implement virtual valve logic with time-based movement simulation.
- The valve state is now set to 'OPEN' immediately when the opening process starts, ensuring a safe and correct state representation.
- The state is only set to 'CLOSED' after the closing process has finished.
- Add persistence for max opening and closing times.
2025-07-01 18:15:54 +02:00