Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Firmware][SDK][Doc] Major refactor and protocol update #63

Closed
wants to merge 165 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
0d37fd2
New state machine for the master board allowing reset after losing co…
maximekli Mar 13, 2020
68e8fec
Adapting master board interface for the new masterboard firmware that…
maximekli Mar 13, 2020
e75d23c
Adapting the example for use with the new master board firmware that …
maximekli Mar 13, 2020
c3c447b
Small method name change to be more consistent with previous code
maximekli Mar 16, 2020
b3faff5
Small change to match previous commit
maximekli Mar 16, 2020
16b17ea
Adapting python master board sdk for use with new state machine
maximekli Mar 16, 2020
2f79564
Adapting python example for use with new master board state machine. …
maximekli Mar 16, 2020
cf85cbf
Adding new error state to the master board state machine in order to …
maximekli Mar 19, 2020
60d9e46
New python test file in the sdk to demonstrate every state of the mas…
maximekli Mar 19, 2020
732add3
Moving the master board state machine test program to its own folder …
maximekli Mar 20, 2020
11de373
Added session id to master board communication
maximekli Mar 20, 2020
0cec437
Added session id handling in sdk interface
maximekli Mar 20, 2020
b5a1682
Change debug printfs location in code for them to work to work
maximekli Mar 23, 2020
420c050
Adding a new timeout to the interface in order to shut it down if we …
maximekli Mar 23, 2020
2fbc667
Adapting the examples for the new interface timeout (while waiting fo…
maximekli Mar 23, 2020
25334da
add feedback on packet loss
AlexisPotier Mar 30, 2020
c8a23a5
Merge branch 'master' of https://github.com/AlexisPotier/master-board
AlexisPotier Mar 30, 2020
2f63fe9
New ethernet lib to work with ESP-IDF v4.0
maximekli Apr 2, 2020
e0e8b97
New default config to work with ESP-IDF v4.0
maximekli Apr 2, 2020
ead964e
New sdkconfig to work with ESP-IDF v4.0 (generated from .defaults)
maximekli Apr 4, 2020
ad51184
Added a new SETUP state to the masterboard code for upcoming changes
maximekli Apr 4, 2020
00e879b
Update .gitignore for current sdk location
maximekli Apr 4, 2020
3f7a983
Adding spi function that blocks until transaction is done and returns…
maximekli Apr 4, 2020
ef0df00
Adding a test of number of slaves connected to MB to only communicate…
maximekli Apr 4, 2020
e7802be
Fix wrong variable name
maximekli Apr 5, 2020
7ce3b9e
Merge branch 'master' of https://github.com/open-dynamic-robot-initia…
maximekli Apr 6, 2020
ace1700
Update masterboard_communication.md
maximekli Apr 6, 2020
8266f28
update feedback packet loss using latest version
AlexisPotier Apr 7, 2020
1ae2827
Added callback function for link state change
maximekli Apr 7, 2020
b497be0
Remove button handling
maximekli Apr 7, 2020
db98e9f
Adding new LINK_DOWN state that handles a physical disconnection with…
maximekli Apr 7, 2020
16c1585
update files to merge
AlexisPotier Apr 7, 2020
440aa82
Merge remote-tracking branch 'origin/patch-1'
AlexisPotier Apr 7, 2020
c7cf87b
Giving feedback on packet loss
AlexisPotier Apr 7, 2020
2e10cd7
Merge branch 'new_branch' of https://github.com/AlexisPotier/master-b…
maximekli Apr 7, 2020
788bcbb
Fix init wifi issue
maximekli Apr 7, 2020
3dbd88d
Merge branch 'AlexisPotier-new_branch'
maximekli Apr 7, 2020
2318392
Handling the case when no link state callback function has been set
maximekli Apr 7, 2020
3be258e
Added state machine documentation
maximekli Apr 8, 2020
385d67a
Update flashing doc for ESP-IDF v4.0
maximekli Apr 8, 2020
4d3a269
Removed temporarily the use of the spi function introduced in commit …
maximekli Apr 8, 2020
a91fb41
Update master board state diagram image
maximekli Apr 8, 2020
eccb291
Merge branch 'master' into new_state_machine
AlexisPotier Apr 9, 2020
9c67af9
Fixed the segmentation fault occurring at the end of the example
AlexisPotier Apr 9, 2020
ae89e7a
Fixed the error (invalid pointer) occurring at the end of the example
AlexisPotier Apr 9, 2020
9ac25cd
Merge remote-tracking branch 'origin/master'
AlexisPotier Apr 10, 2020
08d33e4
Initializing p_trans array to avoid a very rare and specific crash wh…
maximekli Apr 10, 2020
fca6623
Added extra security while allocating for spi transaction memory
maximekli Apr 14, 2020
24c6f25
Completely removed new spi function because api function was not used…
maximekli Apr 14, 2020
4f2d7b4
Small refactor + a few comments
maximekli Apr 14, 2020
8595dc8
Removed state machine test example
maximekli Apr 15, 2020
5b3f5fb
Reset variables for feedback on packet loss after init
maximekli Apr 15, 2020
f0c5437
Making changing states only at the beginning of main callback to prev…
maximekli Apr 15, 2020
b0e01f6
Small refactor
maximekli Apr 15, 2020
577178f
Lttle fix on copying state in main callback
maximekli Apr 15, 2020
58478c5
Added new state for spi autodetection
maximekli Apr 15, 2020
bbc8cbe
Small fix on error states transition
maximekli Apr 15, 2020
0d375d2
Small refactor
maximekli Apr 15, 2020
8d71c47
Small refactor spi_autodetect state
maximekli Apr 16, 2020
0b4a08f
Update state machine doc
maximekli Apr 16, 2020
fbb1d5b
Changes spi_connected from array to uint8_t to be able to send it to PC
maximekli Apr 16, 2020
23a18ec
Added feedback on number of spi slaves connected in ack msg
maximekli Apr 16, 2020
a66f696
Updating interface and examples with the connected spi slaves feedback
maximekli Apr 16, 2020
e694680
Update documentation for feedback on connected SPI slaves
maximekli Apr 16, 2020
b22ddbb
Added protocol version to init msgs in mb firmware
maximekli Apr 17, 2020
7e1786a
Added protocol version to init msgs in interface
maximekli Apr 17, 2020
e9fcaa3
Updated documentation with protocol version in init msgs
maximekli Apr 17, 2020
9856eaa
Specify current protocol version in doc
maximekli Apr 17, 2020
a04e6e6
Fix imu data size in doc
maximekli Apr 17, 2020
b831761
Added an error msg to sensor packet when a spi transaction failed
maximekli Apr 17, 2020
afabd4b
Added failed spi transactions support to example
maximekli Apr 17, 2020
1f320a2
Updated python example with failed spi transactions support
maximekli Apr 17, 2020
50f8ab1
Better handling of variables when there is a state change
maximekli Apr 17, 2020
8ba8298
Added listener mode to the interface that allows to get sensor data f…
maximekli Apr 17, 2020
b3c6155
Adapted both examples for the new listener mode
maximekli Apr 17, 2020
fd67941
Created listener script that gathers sensor data from any connected mb
maximekli Apr 17, 2020
ff17572
Update doc with packet loss
maximekli Apr 20, 2020
356cf8d
Added getters for feedback and changed stats print functions
AlexisPotier Apr 20, 2020
3622043
Merge branch 'feedback_on_packet_loss' of https://github.com/AlexisPo…
maximekli Apr 20, 2020
1c6f017
Merge branch 'AlexisPotier-feedback_on_packet_loss'
maximekli Apr 20, 2020
504ccda
Merge branch 'feedback_on_packet_loss'
AlexisPotier Apr 20, 2020
c053068
Little fix
maximekli Apr 20, 2020
5694521
Small refactor on shutting down the interface
AlexisPotier Apr 21, 2020
93b7cb5
Initialization of bpf in ESPNOW_manager
AlexisPotier Apr 21, 2020
98e65b8
Override stop method to stop differently wifi and ethernet connexions
AlexisPotier Apr 21, 2020
a66c3ae
Rework for listener to work in more cases
maximekli Apr 21, 2020
1e95a2d
Update doc about session id
maximekli Apr 21, 2020
7d52d8e
Small refactor
maximekli Apr 21, 2020
7991607
Added connected status as an attribute in motor_driver class and adap…
maximekli Apr 22, 2020
2725d61
Updated outdated doc
maximekli Apr 23, 2020
cfa9942
Update doc with listener example
maximekli Apr 23, 2020
5686a52
Handling Keyboard Interrupt signal to close threads correctly when th…
AlexisPotier Apr 27, 2020
36870c7
Added default argument for listener mode in interface constructor
maximekli Apr 28, 2020
7837618
Merge pull request #5 from AlexisPotier/master
maximekli Apr 28, 2020
a11c38b
Added extra safety when closing interface
maximekli Apr 29, 2020
7213d5d
Small refactor
maximekli Apr 29, 2020
4014fcb
Added destructors in the interface to close correctly link_handler_ a…
AlexisPotier May 4, 2020
8837692
Close correctly the pthread to avoid memory leaks
AlexisPotier May 4, 2020
6beed8d
Removed "virtual" keyword for stop function in ESPNOW_manager
AlexisPotier May 4, 2020
9ddb53d
Free link_handler when the program is stopped by SIGINT signal
AlexisPotier May 4, 2020
a8872d2
Small refactor when checking drivers
maximekli May 4, 2020
4287d27
Merge branch 'memory_leaks' of https://github.com/AlexisPotier/master…
maximekli May 4, 2020
2f48180
git push origin masterMerge branch 'AlexisPotier-memory_leaks'
maximekli May 4, 2020
3db8ce2
Merge branch 'signal_handler' of https://github.com/AlexisPotier/mast…
maximekli May 4, 2020
1d05db3
git push origin masterMerge branch 'AlexisPotier-signal_handler'
maximekli May 4, 2020
5ff6b40
Small fixes after merge
maximekli May 4, 2020
5fa6ad4
Disabled debug prints
maximekli May 4, 2020
a1e4e51
Merge branch 'signal_handler'
AlexisPotier May 5, 2020
9814600
Merge branch 'memory_leaks'
AlexisPotier May 5, 2020
ad632f2
Merge branch 'master' of https://github.com/maximekli/master-board in…
AlexisPotier May 5, 2020
bd6af73
git push origin masterMerge branch 'maximekli-master'
AlexisPotier May 5, 2020
cdf3f4c
Proper getter and setters for a few driver properties
maximekli May 5, 2020
a21d520
Get first packet loss to avoid jump in value
maximekli May 5, 2020
2bbfbdd
Fix for command loss feedback reset and overflow
AlexisPotier May 7, 2020
4f4a59c
Merge branch 'master' of https://github.com/AlexisPotier/master-board…
maximekli May 7, 2020
f496261
git push origin masterMerge branch 'AlexisPotier-master'
maximekli May 7, 2020
080a3c1
Fix division by zero
maximekli May 7, 2020
cfe40d3
Added member function to check if driver is enabled
maximekli May 8, 2020
75c66d9
Initialization of pointer + extra safety when stopping the interface
maximekli May 11, 2020
77f8247
Updated debug prints
maximekli May 13, 2020
d27a92b
Added set all leds function
maximekli May 13, 2020
8266b17
Removed mistakenly added line in default config
maximekli May 15, 2020
5752474
Changed the protocol to be able to compute the latency for ethernet/w…
AlexisPotier May 20, 2020
12328b3
Creation of a python script to compute the latency of the wifi/ethern…
AlexisPotier May 20, 2020
38a8335
Documentation update : added informations about the latency calculato…
AlexisPotier May 20, 2020
beead35
Changing scheduler param to realtime in examples
maximekli Jun 10, 2020
a2099f7
Merge pull request #13 from AlexisPotier/latency
maximekli Jun 11, 2020
2eda08e
Changed protocol version from 2 to 3
maximekli May 20, 2020
f1682c3
Improving display of latency test result
maximekli May 26, 2020
85b85d2
Revert "Changing scheduler param to realtime in examples"
maximekli Jun 12, 2020
9a490f6
Improved the display of IMU, ADC and motors data
AlexisPotier Jun 17, 2020
02c9dbf
Merged PrintCmdStats and PrintSensorStats, improved the display of wi…
AlexisPotier Jun 17, 2020
51fd8ef
Avoid displaying headers when there is no spi connected
AlexisPotier Jun 18, 2020
b6608bd
Merge branch 'print' of https://github.com/AlexisPotier/master-board …
maximekli Jun 18, 2020
6dad7e7
Merge branch 'AlexisPotier-print'
maximekli Jun 18, 2020
ba0d088
Merge pull request #2 from maximekli/master
AlexisPotier Jun 22, 2020
003d6a1
Enable channel 14 for wifi communication
AlexisPotier Jun 24, 2020
ad4a7ae
Added getters for wifi channel and protocol version
AlexisPotier Jun 24, 2020
b98776e
Replaced latency script by communication analyser script
AlexisPotier Jun 24, 2020
9e9781e
Small refactor
AlexisPotier Jul 1, 2020
c3fc74a
Merge pull request #15 from AlexisPotier/communication
maximekli Jul 1, 2020
b549c64
Autoselection between ethernet and wifi and autoselection of wifi cha…
AlexisPotier Jul 6, 2020
f6fac75
Update state machine documentation
AlexisPotier Jul 6, 2020
5f3fb8d
Small corrections
AlexisPotier Jul 6, 2020
9fa1b5b
Merge pull request #16 from AlexisPotier/wifi_eth_autoselect
maximekli Jul 6, 2020
644d960
Removed wifi channel menuconfig entry and tcpip adpater use
maximekli Jul 7, 2020
9e28920
Fixed typo in ethernet library
maximekli Jul 7, 2020
74a5afd
New sdkconfig for v4.0.1
maximekli Jul 7, 2020
90d92b5
Update masterboard_state_machine.md
maximekli Jul 7, 2020
e60fd9f
Merge pull request #3 from maximekli/master
AlexisPotier Jul 7, 2020
53419a6
Fixed wifi deinit and channel change issue
maximekli Jul 7, 2020
881d31b
Removed listener mode special case because mb does not send packets i…
maximekli Jul 8, 2020
c5b315b
Fixed typo
maximekli Jul 9, 2020
efdf647
Small fix for wifi event handlers
maximekli Jul 15, 2020
d0ed781
Better way to get wifi channel
AlexisPotier Jul 15, 2020
d810ff0
Merge pull request #17 from AlexisPotier/communication
maximekli Jul 15, 2020
258145d
Plot graphs even if the script is stopped by a master board timeout
AlexisPotier Jul 21, 2020
7e66eec
Fixed overflow issue on com_analyser
AlexisPotier Jul 22, 2020
2e98f3d
Merge pull request #18 from AlexisPotier/communication
maximekli Jul 22, 2020
1c73e23
SPI: using polling instead of interrupts
maximekli Jun 12, 2020
33123ff
SPI: disable use of DMA (easier for memory management)
maximekli Jun 29, 2020
fcf0c5b
Placed spi pre and post cbs into IRAM
maximekli Jul 16, 2020
dedb48d
Temporary fix for IMU interrupt issue
maximekli Jul 31, 2020
35b86bb
Temporary fix failing spi transactions in error state
maximekli Jul 31, 2020
53b894e
Update doc
maximekli Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

firmware/build/

sdk/bin/
sdk/build/
sdk/master_board_sdk/bin/
sdk/master_board_sdk/build/
sdk/master_board_sdk/graphs/

firmware/sdkconfig\.old

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ Documentation
-------------
Here are some helpful links to the documentation :

[How to flash the Master Board (install esp-idf and flash the firmware)]( firmware/README.md )
[How to flash the Master Board (install esp-idf and flash the firmware)](firmware/README.md)

[SDK : How to prepare your interface and run the example](sdk/master_board_sdk/README.md )

[Description of the communication between the Master Board and the computer]( documentation/masterboard_communication.md )
[Master Board State Machine Description](documentation/masterboard_state_machine.md)

[Description of the BLMC µDriver SPI interface]( documentation/BLMC_%C2%B5Driver_SPI_interface.md )
[Description of the communication between the Master Board and the computer](documentation/masterboard_communication.md)

[Description of the BLMC µDriver SPI interface](documentation/BLMC_%C2%B5Driver_SPI_interface.md)

[Wiring the MasterBoard](documentation/masterboard_wiring.md)

Expand Down
2 changes: 1 addition & 1 deletion documentation/BLMC_µDriver_SPI_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ES | EM1 | EM2 | EPRE | EI1OC | EI2OC | - | - | Timeout | Timeout | Timeout | Ti
|---|---|---|
ES<15> (Enable System) | 0: Disable the system, motor can not be controlled<br>1: Enable the system| When the system is disabled, no current is sent to the motor. This can be useful to trigger a safety stop. |
EM1 <14> (Enable Motor 1) | 0: Disable Motor 1<br>1: Enable Motor 1 | Enabling Motor will trigger the calibration procedure, aligning the rotor to a known magnetic field orientation. Minimal load should be applied while calibrating the motor. |
EM2 <13> (Enable Motor 1) | 0: Disable Motor 2<br>1: Enable Motor 2 | Enabling Motor will trigger the calibration procedure, aligning the rotor to a known magnetic field orientation. Minimal load should be applied while calibrating the motor. |
EM2 <13> (Enable Motor 2) | 0: Disable Motor 2<br>1: Enable Motor 2 | Enabling Motor will trigger the calibration procedure, aligning the rotor to a known magnetic field orientation. Minimal load should be applied while calibrating the motor. |
EPRE <12> (Enable Position Rollover Error for both motors) | 0: Disable the Rollover Error<br>1: Enable the Rollover Error | Rollover can happen if position is coded with a maximum range from -128 to 128 (approximately, see Data representation below). Enable the Rollover error will generate an error reported in the Status Field and will disable the system. |
EI1OC <11> (Enable Index 1 Offset Compensation) | 0: Disable Index Offset Compensation <br>1: Enable Index Offset Compensation | Incremental encoders often include an index line that can help to deduce the absolute position of the rotor shaft modulo one turn.<br>If EIxOC is set to one, and if IDXxD has been reported in the Status word, Position will be offset to be zero at the first index detected.<br>/!\ WARNING: Setting this bit will cause the position to jump. User need to take extra care if closed loop controller uses the position as feedback. |
EI2OC <10> (Enable Index 2 Offset Compensation) | 0: Disable Index Offset Compensation <br>1: Enable Index Offset Compensation | Incremental encoders often include an index line that can help to deduce the absolute position of the rotor shaft modulo one turn.<br>If EIxOC is set to one, and if IDXxD has been reported in the Status word, Position will be offset to be zero at the first index detected.<br>/!\ WARNING: Setting this bit will cause the position to jump. User need to take extra care if closed loop controller uses the position as feedback. |
Expand Down
42 changes: 31 additions & 11 deletions documentation/masterboard_communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,36 @@ The interface on the PC needs to support monitor mode and injection. ASUS PCE-AC

Data packet
-----------

### Current protocol version: **3**

Both WiFi and Ethernet use the same data packet format.

There are two types of packets. Packets coming from the computer are called **Command** packets, and packets coming from the master board are called **Sensor** packets.
There are four types of packets. Packets coming from the computer containing command data are called **Command** packets, and packets coming from the master board containing sensor data are called **Sensor** packets. On top of these two, an initialization packet called **Init** packet is used to put the master board in its control mode and bond it to an interface running on the computer. The master board will respond to an initialization packet with an acknowledgement packet called **Ack** packet.

All packets contain a number called **Session ID** identifyng the link between the master board and a specific instance of the interface. This is used to prevent multiple programs from controlling the robot at once. The **Init** packet is used to set it up.
**Session Id** of **0** is reserved for when the masterboard boots up and should not be used otherwise.

### Init packet (4 Bytes)
Protocol version | Session ID |
--- | ---
2 bytes | 2 bytes

The **Protocol version** field is used to ensure both the interface and the masterboard firmware use the same protocol. The master board checks it when receiving an **Init** packet.

### Ack packet (3 Bytes)
Session ID | SPI connected
--- | ---
2 bytes | 1 byte

Both packets encapsulate 6 BLMC µDriver SPI interface packets, without the **Index** and **CRC** fields. Additional, sensor packets also include IMU measurement and AHRS estimation.
The **SPI connected** field contains an 8 bit integer, each bit of which tells whether or not the corresponding SPI slave is connected (Least significant bit: SPI0, most significant bit: SPI7).

Both **Command** and **Sensor** packets encapsulate 6 BLMC µDriver SPI interface packets, without the **Index** and **CRC** fields. Additional, sensor packets also include IMU measurement and AHRS estimation.

### Sensor packet (196 Bytes)
µDriver0 | µDriver1 | µDriver2 | µDriver3 | µDriver4 | µDriver5 | IMU | Sensor Index | Last Command Index
--- | --- | --- | --- | --- | --- | --- | --- | ---
28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 18 Bytes | 2 Bytes | 2 Bytes
### Sensor packet (200 Bytes)
Session ID | µDriver0 | µDriver1 | µDriver2 | µDriver3 | µDriver4 | µDriver5 | IMU | Sensor Index | Packet Loss | Last Command Index
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
2 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 24 Bytes | 2 Bytes | 2 Bytes | 2 Bytes

**µDriverX** corresponds to a BLMC µDriver SPI interface sensor packet without the CRC and index fields.

Expand All @@ -66,13 +85,14 @@ AHRS R-P-Y | 16bits | rad | -4 | 3,9998779297 | 2^(-13)

**Sensor Index** is a packet index to track packet loss.

**Last Command Index** is the index of the last received command index, and can be used to track packet loss.
**Packet Loss** is the number of command packets lost since the initialization, computed by the master board using **Command Packet**'s **Command Index**.

**Last Command Index** is the index of the last **Command Packet** received, used to compute the latency of the communication

### Command packet (170 Bytes)
µDriver0 | µDriver1 | µDriver2 | µDriver3 | µDriver4 | µDriver5 | Command Index
--- | --- | --- | --- | --- | --- | ---
28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 2 Bytes
### Command packet (172 Bytes)
Session ID | µDriver0 | µDriver1 | µDriver2 | µDriver3 | µDriver4 | µDriver5 | Command Index
--- | --- | --- | --- | --- | --- | --- | ---
2 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 28 Bytes | 2 Bytes

**µDriverX** corresponds to a BLMC µDriver SPI interface command packet without the CRC and index fields.

Expand Down
27 changes: 27 additions & 0 deletions documentation/masterboard_state_machine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Master Board State Machine

The master board runs a state machine that handles the differents stages of communication and errors that can occur.

State machine description and behaviour
---
[![master board state machine diagram](../images/master_board_state_machine.svg)](https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtXG4gICAgc3RhdGUgXCJTRVRVUFwiIGFzIFNFVFVQOiBTZXR0aW5nIHVwIGFsbCBjb21wb25lbnRzXG4gICAgc3RhdGUgXCJXQUlUSU5HX0ZPUl9JTklUXCIgYXMgV0FJVElOR19GT1JfSU5JVDogV2FpdGluZyBmb3IgYW4gSW5pdCBwYWNrZXQgZnJvbSBQQ1xuICAgIHN0YXRlIFwiU1BJX0FVVE9ERVRFQ1RcIiBhcyBTUElfQVVUT0RFVEVDVDogRGV0ZWN0aW5nIGNvbm5lY3RlZCBTUEkgc2xhdmVzXG4gICAgc3RhdGUgXCJTRU5ESU5HX0lOSVRfQUNLXCIgYXMgU0VORElOR19JTklUX0FDSzogU2VuZGluZyBBY2tub3dsZWRnZW1lbnQgcGFja2V0IHRvIFBDXG4gICAgc3RhdGUgXCJBQ1RJVkVfQ09OVFJPTFwiIGFzIEFDVElWRV9DT05UUk9MOiBSb2JvdCBhY3RpdmVseSBjb250cm9sbGVkIGJ5IHRoZSBQQ1xuICAgIHN0YXRlIFwiV0lGSV9FVEhfTElOS19ET1dOXCIgYXMgV0lGSV9FVEhfTElOS19ET1dOOiBFdGhlcm5ldCBsaW5rIGlzIGRvd25cbiAgICBzdGF0ZSBcIldJRklfRVRIX0VSUk9SXCIgYXMgV0lGSV9FVEhfRVJST1I6IFRpbWVvdXQsIG5vIHBhY2tldCBmcm9tIFBDXG5cbiAgICBbKl0gLS0-IFNFVFVQXG4gICAgU0VUVVAgLS0-IFdBSVRJTkdfRk9SX0lOSVQ6IFNldHVwIGRvbmUgaW4gV2lGaVxuICAgIFxuICAgIFdJRklfRVRIX0xJTktfRE9XTiAtLT4gV0lGSV9FVEhfRVJST1I6IEV0aGVybmV0IExpbmsgVXBcblxuICAgIFdBSVRJTkdfRk9SX0lOSVQgLS0-IFNQSV9BVVRPREVURUNUOiBJbml0IHBhY2tldCByZWNlaXZlZFxuICAgIFxuICAgIFNQSV9BVVRPREVURUNUIC0tPiBTRU5ESU5HX0lOSVRfQUNLOiBOdW1iZXIgb2YgdGVzdCB0cmFuc2FjdGlvbnMgZXhjZWVkZWRcblxuICAgIFNFTkRJTkdfSU5JVF9BQ0sgLS0-IFdJRklfRVRIX0VSUk9SOiBUaW1lb3V0IGFja25vd2xlZGdlbWVudFxuICAgIFNFTkRJTkdfSU5JVF9BQ0sgLS0-IEFDVElWRV9DT05UUk9MOiBGaXJzdCBjb21tYW5kIHBhY2tldCByZWNlaXZlZFxuXG4gICAgQUNUSVZFX0NPTlRST0wgLS0-IFdJRklfRVRIX0VSUk9SOiBUaW1lb3V0IGNvbnRyb2xcblxuICAgIFdJRklfRVRIX0VSUk9SIC0tPiBTUElfQVVUT0RFVEVDVDogSW5pdCBwYWNrZXQgcmVjZWl2ZWRcbiIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In19)

Diagram generated using [Mermaid](https://github.com/mermaid-js/mermaid) Live Editor, click on picture to edit.

During **WAITING_FOR_INIT**, the master board waits for an init message from both ethernet and wifi, checking all channels. This enables an autoselection of the type of communication with the computer.

Please note that **WIFI_ETH_LINK_DOWN** state is accessible from any state except WAITING_FOR_INIT via a callback on the ethernet link down event, but links have not been drawn for the sake of readability.

State machine LED code
---
To each state is associated a LED behaviour.

State | LED behaviour
--- | ---
SETUP | Steady White
WAITING_FOR_INIT | Red Fade
SPI_AUTODETECT | Magenta Fade
SENDING_INIT_ACK | Blue Fade
ACTIVE_CONTROL | Green Fade
WIFI_ETH_LINK_DOWN | Yellow Blink
WIFI_ETH_ETH_ERROR | Red Blink
16 changes: 2 additions & 14 deletions firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Install esp-idf
--------
The master board is based on a ESP32 module programmed in C++ using the expressif idf SDK https://github.com/espressif/esp-idf

To install the SDK simply follow the instruction form https://docs.espressif.com/projects/esp-idf/en/stable/get-started/.

Please checkout the github issue about the esp-idf version: https://github.com/open-dynamic-robot-initiative/master-board/issues/3.
To install the SDK (v4.0.1) simply follow the instruction form https://docs.espressif.com/projects/esp-idf/en/v4.0.1/get-started/index.html.

Firmware of the ESP32 can be found here https://github.com/open-dynamic-robot-initiative/master-board.

Expand All @@ -30,17 +28,7 @@ On a freshly assembled board, we first need to burn a configuration fuse becaus

`python espefuse.py set_flash_voltage 3.3V`

To flash the board, the esp environment variables must be sourced and a special branch must be checked out. Assuming the `esp-idf` installation is under `~/esp/esp-idf`:

```
cd ~/esp/esp-idf
git checkout v4.0 # The export.sh is only available at newer versions.
source export.sh
git checkout 8d1a9c0 # Need to checkout this old version for now
git submodule update --init --recursive
```

Then, from the `master-board/firmware` folder, you can run:
To flash the board, from the `master-board/firmware` folder, you can run:

* Flash the board: `make flash`
* Change configurations: `make menuconfig`
Expand Down
Loading