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

Add read-flash support #558

Merged
merged 8 commits into from
Feb 1, 2024
Merged

Add read-flash support #558

merged 8 commits into from
Feb 1, 2024

Conversation

SergioGasquez
Copy link
Member

@SergioGasquez SergioGasquez commented Jan 22, 2024

Tests

espflash

espflash/espflash on  feat/commands [$!?] is 📦 v3.0.0-dev via 🦀 v1.77.0-nightly 
❯ cargo r -r -- read-flash  0 0x200 flash_content.bin
    Finished release [optimized] target(s) in 0.07s
     Running `/home/sergio/Documents/Espressif/forks/espflash/target/release/espflash read-flash 0 0x200 flash_content.bin`
[2024-01-22T11:05:48Z INFO ] Serial port: '/dev/ttyACM0'
[2024-01-22T11:05:48Z INFO ] Connecting...
[2024-01-22T11:05:49Z INFO ] Using flash stub
Chip type:         esp32c3 (revision v0.3)
Crystal frequency: 40MHz
Flash size:        4MB
Features:          WiFi, BLE
MAC address:       60:55:f9:c0:39:7c

espflash/espflash on  feat/commands [$!?] is 📦 v3.0.0-dev via 🦀 v1.77.0-nightly 
❯ hexdump -C flash_content.bin 
00000000  e9 03 02 20 10 c7 3c 40  ee 00 00 00 05 00 03 03  |... ..<@........|
00000010  00 c7 00 00 00 00 00 01  20 58 cd 3f 14 17 00 00  |........ X.?....|
00000020  ff ff ff ff 41 73 73 65  72 74 20 66 61 69 6c 65  |....Assert faile|
00000030  64 20 69 6e 20 25 73 2c  20 25 73 3a 25 64 20 28  |d in %s, %s:%d (|
00000040  25 73 29 0d 0a 00 00 00  61 62 6f 72 74 28 29 20  |%s).....abort() |
00000050  77 61 73 20 63 61 6c 6c  65 64 20 61 74 20 50 43  |was called at PC|
00000060  20 30 78 25 30 38 78 0d  0a 00 00 00 62 6f 6f 74  | 0x%08x.....boot|
00000070  00 00 00 00 1b 5b 30 3b  33 31 6d 45 20 28 25 6c  |.....[0;31mE (%l|
00000080  75 29 20 25 73 3a 20 6c  6f 61 64 20 70 61 72 74  |u) %s: load part|
00000090  69 74 69 6f 6e 20 74 61  62 6c 65 20 65 72 72 6f  |ition table erro|
000000a0  72 21 1b 5b 30 6d 0a 00  20 69 73 20 6e 6f 74 20  |r!.[0m.. is not |
000000b0  62 6f 6f 74 61 62 6c 65  00 00 00 00 1b 5b 30 3b  |bootable.....[0;|
000000c0  33 31 6d 45 20 28 25 6c  75 29 20 25 73 3a 20 46  |31mE (%lu) %s: F|
000000d0  61 63 74 6f 72 79 20 61  70 70 20 70 61 72 74 69  |actory app parti|
000000e0  74 69 6f 6e 25 73 1b 5b  30 6d 0a 00 1b 5b 30 3b  |tion%s.[0m...[0;|
000000f0  33 31 6d 45 20 28 25 6c  75 29 20 25 73 3a 20 46  |31mE (%lu) %s: F|
00000100  61 63 74 6f 72 79 20 74  65 73 74 20 61 70 70 20  |actory test app |
00000110  70 61 72 74 69 74 69 6f  6e 25 73 1b 5b 30 6d 0a  |partition%s.[0m.|
00000120  00 00 00 00 1b 5b 30 3b  33 31 6d 45 20 28 25 6c  |.....[0;31mE (%l|
00000130  75 29 20 25 73 3a 20 4f  54 41 20 61 70 70 20 70  |u) %s: OTA app p|
00000140  61 72 74 69 74 69 6f 6e  20 73 6c 6f 74 20 25 64  |artition slot %d|
00000150  25 73 1b 5b 30 6d 0a 00  1b 5b 30 3b 33 32 6d 49  |%s.[0m...[0;32mI|
00000160  20 28 25 6c 75 29 20 25  73 3a 20 4c 6f 61 64 65  | (%lu) %s: Loade|
00000170  64 20 61 70 70 20 66 72  6f 6d 20 70 61 72 74 69  |d app from parti|
00000180  74 69 6f 6e 20 61 74 20  6f 66 66 73 65 74 20 30  |tion at offset 0|
00000190  78 25 78 1b 5b 30 6d 0a  00 00 00 00 1b 5b 30 3b  |x%x.[0m......[0;|
000001a0  33 31 6d 45 20 28 25 6c  75 29 20 25 73 3a 20 45  |31mE (%lu) %s: E|
000001b0  72 72 6f 72 20 69 6e 20  77 72 69 74 65 5f 6f 74  |rror in write_ot|
000001c0  61 64 61 74 61 20 6f 70  65 72 61 74 69 6f 6e 2e  |adata operation.|
000001d0  20 65 72 72 20 3d 20 30  78 25 78 1b 5b 30 6d 0a  | err = 0x%x.[0m.|
000001e0  00 00 00 00 1b 5b 30 3b  33 32 6d 49 20 28 25 6c  |.....[0;32mI (%l|
000001f0  75 29 20 25 73 3a 20 53  65 74 20 61 63 74 75 61  |u) %s: Set actua|
00000200

esptool

espflash/espflash on  feat/commands [$!?] is 📦 v3.0.0-dev via 🦀 v1.77.0-nightly took 4s 
❯ esptool.py --port /dev/ttyACM0 read_flash 0 0x200 flash_content.bin
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting...
Detecting chip type... ESP32-C3
Chip is ESP32-C3 (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 60:55:f9:c0:39:7c
Uploading stub...
Running stub...
Stub running...
512 (100 %)
512 (100 %)
Read 512 bytes at 0x00000000 in 0.0 seconds (90.8 kbit/s)...
Hard resetting via RTS pin...

espflash/espflash on  feat/commands [$!?] is 📦 v3.0.0-dev via 🦀 v1.77.0-nightly 
❯ hexdump -C flash_content.bin
00000000  e9 03 02 20 10 c7 3c 40  ee 00 00 00 05 00 03 03  |... ..<@........|
00000010  00 c7 00 00 00 00 00 01  20 58 cd 3f 14 17 00 00  |........ X.?....|
00000020  ff ff ff ff 41 73 73 65  72 74 20 66 61 69 6c 65  |....Assert faile|
00000030  64 20 69 6e 20 25 73 2c  20 25 73 3a 25 64 20 28  |d in %s, %s:%d (|
00000040  25 73 29 0d 0a 00 00 00  61 62 6f 72 74 28 29 20  |%s).....abort() |
00000050  77 61 73 20 63 61 6c 6c  65 64 20 61 74 20 50 43  |was called at PC|
00000060  20 30 78 25 30 38 78 0d  0a 00 00 00 62 6f 6f 74  | 0x%08x.....boot|
00000070  00 00 00 00 1b 5b 30 3b  33 31 6d 45 20 28 25 6c  |.....[0;31mE (%l|
00000080  75 29 20 25 73 3a 20 6c  6f 61 64 20 70 61 72 74  |u) %s: load part|
00000090  69 74 69 6f 6e 20 74 61  62 6c 65 20 65 72 72 6f  |ition table erro|
000000a0  72 21 1b 5b 30 6d 0a 00  20 69 73 20 6e 6f 74 20  |r!.[0m.. is not |
000000b0  62 6f 6f 74 61 62 6c 65  00 00 00 00 1b 5b 30 3b  |bootable.....[0;|
000000c0  33 31 6d 45 20 28 25 6c  75 29 20 25 73 3a 20 46  |31mE (%lu) %s: F|
000000d0  61 63 74 6f 72 79 20 61  70 70 20 70 61 72 74 69  |actory app parti|
000000e0  74 69 6f 6e 25 73 1b 5b  30 6d 0a 00 1b 5b 30 3b  |tion%s.[0m...[0;|
000000f0  33 31 6d 45 20 28 25 6c  75 29 20 25 73 3a 20 46  |31mE (%lu) %s: F|
00000100  61 63 74 6f 72 79 20 74  65 73 74 20 61 70 70 20  |actory test app |
00000110  70 61 72 74 69 74 69 6f  6e 25 73 1b 5b 30 6d 0a  |partition%s.[0m.|
00000120  00 00 00 00 1b 5b 30 3b  33 31 6d 45 20 28 25 6c  |.....[0;31mE (%l|
00000130  75 29 20 25 73 3a 20 4f  54 41 20 61 70 70 20 70  |u) %s: OTA app p|
00000140  61 72 74 69 74 69 6f 6e  20 73 6c 6f 74 20 25 64  |artition slot %d|
00000150  25 73 1b 5b 30 6d 0a 00  1b 5b 30 3b 33 32 6d 49  |%s.[0m...[0;32mI|
00000160  20 28 25 6c 75 29 20 25  73 3a 20 4c 6f 61 64 65  | (%lu) %s: Loade|
00000170  64 20 61 70 70 20 66 72  6f 6d 20 70 61 72 74 69  |d app from parti|
00000180  74 69 6f 6e 20 61 74 20  6f 66 66 73 65 74 20 30  |tion at offset 0|
00000190  78 25 78 1b 5b 30 6d 0a  00 00 00 00 1b 5b 30 3b  |x%x.[0m......[0;|
000001a0  33 31 6d 45 20 28 25 6c  75 29 20 25 73 3a 20 45  |31mE (%lu) %s: E|
000001b0  72 72 6f 72 20 69 6e 20  77 72 69 74 65 5f 6f 74  |rror in write_ot|
000001c0  61 64 61 74 61 20 6f 70  65 72 61 74 69 6f 6e 2e  |adata operation.|
000001d0  20 65 72 72 20 3d 20 30  78 25 78 1b 5b 30 6d 0a  | err = 0x%x.[0m.|
000001e0  00 00 00 00 1b 5b 30 3b  33 32 6d 49 20 28 25 6c  |.....[0;32mI (%l|
000001f0  75 29 20 25 73 3a 20 53  65 74 20 61 63 74 75 61  |u) %s: Set actua|
00000200

@SergioGasquez SergioGasquez changed the title Add read-flash support and add missing commands Add read-flash support Jan 22, 2024
@SergioGasquez SergioGasquez linked an issue Jan 22, 2024 that may be closed by this pull request
@SergioGasquez
Copy link
Member Author

@t-moe also confirmed that it worked for him: #539 (comment)

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Feel free to ignore the comment about reverting the enum names, it's not a big deal and I'm guessing this brings us inline with esptools naming convention?

espflash/src/command.rs Show resolved Hide resolved
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@MabezDev MabezDev merged commit be61f8a into esp-rs:main Feb 1, 2024
20 checks passed
@SergioGasquez SergioGasquez deleted the feat/commands branch February 1, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support reading flash
2 participants