-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
mcuboot/samples/zephyr (make test-good-rsa) doesn't work #22903
Comments
Are you using Zephyr's built-in MCUBoot or upstream MCUBoot? |
Sorry, but please let me know what the difference is. |
Since I don't change released files other than dts file, it should be followed by Makefile as shown below. So mcuboot files are used at mcuboot/boot/zephyr SOURCE_DIRECTORY := $(CURDIR) boot: check |
cc @utzig |
@kkiyota Could you please paste your |
Here is mcuboot/samples/zephyr/build/nucleo_f767zi/mcuboot/zephyr/.config If you need anything else, please let me know. ////////////////////////////////////////////////////////////// |
@kkiyota Yeah, that ended up quite unreadable :-P You should put it in a non-formatted block of text, anyways I think the issue is with the partitions you used, I was looking how I configured them for Mynewt and since there are non-linear sector sizes I would suggest you test with the same partition structure which would be:
|
@utzig I have no idea how I can paste as a plain text here. Instead, I added it as a text file. Please review it again. I'll try using your partition later and let you know. Thank you, |
It is known that the samples/zephyr makefile likely will only work for the frdm_k64f. Both the flash programming, as well as assumptions about partition positions. We have it as an issue in MCUboot: mcu-tools/mcuboot#213. |
@d3zd3z Do you mean that I should wait until mcu-tools/mcuboot#213 will be resolved? |
@kkiyota Would be nice if you could test with the suggested partition changes. |
@utzig I'll work on it tomorrow due to conflict. |
@utzig Could you also let me know your points? The difference between your partition map and mine is just slots' capacity. |
@kkiyota The sectors are not linear in the STM32F7, which means not all sectors have the same size, you are starting a slot in a smaller sector which can't be swapped. |
@utzig In my dts file as attached below again, both slot0 and slot1 are 256KB. Are you referring to this file? Or anything else? /// flash partition definition in zephyr/boards/arm/nucleo_f767zi/nucleo_f767zi.dts ///////
}; |
The sector at 0x20000 is 128KB, which means you are using one sector plus half of the next sector (which is 256KB). MCUBoot in swap mode does not allow that.
The sector at 0x60000 is 256KB so this is one is OK. |
@utzig Thank you for your reply! Looking at Zephyr document as shown below, the first parameter is defined as offset, and second one is capacity. Are you referring to the different spec? ////////////////////////////////////////////////////////////////////////////////////// partitions {
}; partitionX_label are device tree labels that can be used elsewhere in the device tree to refer to the partition START_OFFSET_x is the start offset in hexadecimal notation of the partition from the beginning of the flash device SIZE_x is the hexadecimal size, in bytes, of the flash partition |
bug label removed as this is usage fault by incompatible partition configuration. |
@nvlsianpu Could you point out where my definition is incorrect if you think so? |
I tested now with the partition configuration I have submitted earlier and I can confirm it can successfully upgrade and revert. I have built manually the bootloader and hello_word sample app, so maybe there might exist an issue with the build system that @d3zd3z mentioned. I might try to test that tomorrow as well.
As I wrote before "The sector at 0x20000 is 128KB, which means you are using one sector plus half of the next sector (which is 256KB)", can it be more clear than this? Maybe try reading the reference manual: https://www.st.com/content/ccc/resource/technical/document/reference_manual/group0/96/8b/0d/ec/16/22/43/71/DM00224583/files/DM00224583.pdf/jcr:content/translations/en.DM00224583.pdf Go to page 88/1954, the sector at 0x20000 is 128KB and you can't mix sectors of different sizes; also you are describing it as 256KB in your DTS so it will use one sector + half sector. Your offsets should be updated to use the ones I have pasted here before; the size of the slots is not so important, I used 0xc0000 avoid wastings space, but it's fine if you want to stay with 0x40000. |
@utzig Thank you for sending me ST document link! I didn’t know such NAND FLASH block limitation. I’ll try it ASAP. |
@utzig I ran some experiments.
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
//// /// Terminal screen /// Best regards, |
I have no idea why |
The Makefile that builds hello2 hardcodes everything about the partition, both when calling |
@d3zd3z I just changed "--slot-size" assuming that it's the same as slot0 and slo1 partition size. Is it correct understanding? //////////////////////////// Build and sign "hello1".hello1: check Build and sign "hello2".This is the same signing command as above, except that it adds the"--pad" argument. This will also add the trailer that indicatesthis image is intended to be an upgrade. It should be flashed intothe secondary slot instead of the primary slot.hello2: check |
@utzig Yes, I can compile it with no errors. When signed-hello2.bin was loaded, I just got the error which looks error for erase. |
Hi, Looking at my error message in case of 2 x 256KB sectors for slot1 (Sector 7 and 8) , erase error seems to occur at 0x8120000 which is in Sector 8. pyocd option for erase is set as sector erase as a default. However, it seems that there is no way to specify the 2 sectors erase. And it's not clear how erase and program operations are proceeded. There is the description in pyocd document that pyocd doesn't run erase operation in "pyocd flash" command, but it looks erase operation was run. Does anyone know how I can specify arguments for "pyocd flash" command or anything else? In case of single sector dts configuration, it works fine. So I guess there may be additional cares required for >2 sectors case. Regards, /////////////////////
|
Referring to the log file, this flash may be configured as dual bank mode which is defined in Table 4 below instead of single bank mode in Table 3. So in my last case with the following slot1_partition, it would be overlapped to Bank 2. I need to check it furthermore, though.
|
I also confirmed by register read that flash controller in stm32f767zi was configured as single bank mode. However, pyocd log info showed erase operation was performed by 128KB(target sector size in dual bank mode) instead of 256KB(target sector size in single bank mode). So I guess my problem is related to pyocd. Since my board files for nucleo-f767zi doesn't work with pyocd, I'm currently using Keil.STM32F7xx_DFP.2.12.0.pack which was downloaded from ARM site. Any idea? |
I use almost exclusively this tooling with STM32s: https://github.com/texane/stlink |
@utzig Thank you! Is it different from ST supplied tools? |
I don't know what tools ST are supplying these days, but stlink is open-source and works on 100% of the boards I use (with no configuration required). |
@utzig Thanks! In your case, does stlink work fine with 2 sectors of slot0 and slot1 like 256KB x2 in single bank mode? |
Yes, I have absolutely no issues, I use a lot of STM32 boards (20 or more) and everything works 100%. |
@utzig Sounds good! I'll implement and run with it. |
@utzig I installed stlink thru Ubuntu Software store. In case of slot0=slot1=scratch=256KB, swap case works fine. However, in case of slot0=slot1=scratch=512KB or slot0=slot1=768KB/ scratch=256KB, hello1 was executed although flash write operation was performed well. Expected result is that hello2 is run temporally and revert it on reset. My set-flash command for hello2 is listed below. Is it correct command? Any idea why only 256KB case could work?
|
@utzig Looks like I forgot to change --slot-size during imgtoo.py execution. After I fixed it, everything looks fine as shown below in case of slot0=slot1=768KB and scratch=256KB. Appreciated your help!
|
Describe the bug
Using mcuboot/samples/zephyr, overwrite test case can work fine as shown below, where slot0 is overwritten by slot1. However, swap case(make test-good-rsa) doesn't work.
Could you let me know how I can debug it?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
According to Makefile, expectation should be described below.
//# Test a good image, with a good upgrade, using RSA signatures.
//# flash_boot: Unable to find bootable image
//# flash_hello1: hello1 runs
//# flash_hello2: hello2 runs
//# reset: hello1 runs
Impact
Showstopper
Screenshots or console output
/// make test-overwrite case (working) ////
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
[00:00:00.005,000] mcuboot: Starting bootloader
[00:00:00.011,000] mcuboot: Swap type: none
[00:00:00.016,000] mcuboot: Unable to find bootable image
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
[00:00:00.005,000] mcuboot: Starting bootloader
[00:00:00.011,000] mcuboot: Swap type: none
[00:00:00.066,000] mcuboot: Bootloader chainload address offset: 0x20000
[00:00:00.073,000] mcuboot: Jumping to the first image slot�*** Booting Zephyr OS build zephyr-v2.1.0-*
Hello World from hello1 on nucleo_f767zi!
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
[00:00:00.005,000] mcuboot: Starting bootloader
[00:00:00.011,000] mcuboot: Swap type: test
[00:00:00.066,000] mcuboot: Image upgrade secondary slot -> primary slot
[00:00:00.073,000] mcuboot: Erasing the primary slot
[00:00:00.595,000] mcuboot: Copying the secondary slot to the primary slot: 0x20000 bytes
[00:00:07.442,000] mcuboot: Bootloader chainload address offset: 0x20000
[00:00:07.450,000] mcuboot: Jumping to the first image slot�*** Booting Zephyr OS build zephyr-v2.1.0-*
Hello World from hello2 on nucleo_f767zi!
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/// make test-good-rsa case (not working) ////
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
[00:00:00.005,000] mcuboot: Starting bootloader
[00:00:00.011,000] mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.021,000] mcuboot: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.030,000] mcuboot: Boot source: primary slot
[00:00:00.039,000] mcuboot: Swap type: none
[00:00:00.044,000] mcuboot: Unable to find bootable image
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
[00:00:00.005,000] mcuboot: Starting bootloader
[00:00:00.011,000] mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.021,000] mcuboot: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.030,000] mcuboot: Boot source: primary slot
[00:00:00.039,000] mcuboot: Swap type: none
[00:00:00.095,000] mcuboot: Bootloader chainload address offset: 0x20000
[00:00:00.102,000] mcuboot: Jumping to the first image slot�*** Booting Zephyr OS build zephyr-v2.1.0-*
Hello World from hello1 on nucleo_f767zi!
*** Booting Zephyr OS build zephyr-v2.1.0-1214-g22326f6d99e8 ***
[00:00:00.005,000] mcuboot: Starting bootloader
[00:00:00.011,000] mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.021,000] mcuboot: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.030,000] mcuboot: Boot source: primary slot
[00:00:00.039,000] mcuboot: Swap type: test
[00:00:00.109,000] os: ***** BUS FAULT *****
[00:00:00.115,000] os: Precise data bus error
[00:00:00.120,000] os: BFAR Address: 0x20080004
[00:00:00.126,000] os: r0/a1: 0x20080000 r1/a2: 0x0000bc71 r2/a3: 0x00003384
[00:00:00.135,000] os: r3/a4: 0xffffc537 r12/ip: 0x00040000 r14/lr: 0x080007d3
[00:00:00.144,000] os: xpsr: 0x81000000
[00:00:00.149,000] os: Faulting instruction address (r15/pc): 0x08005d5e
[00:00:00.157,000] os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.165,000] os: Current thread: 0x20022b74 (unknown)
[00:00:00.172,000] os: Halting system
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/// flash partition definition in zephyr/boards/arm/nucleo_f767zi/nucleo_f767zi.dts ///////
&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/devices/dts/flash_partitions.html
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Best regards,
Koji
The text was updated successfully, but these errors were encountered: