initialize pin before booting device.

Hi ,

      I want to use a pin on board, which is not used or initialized in dts file . my requirement is that I want to initialize that pin before booting process. ( that pin act as power supply for my external flash device). so kindly suggest on that. why before booting process is, while performing dfu from external flash after booting it is directly checking the flash related thing so before that i need to set that pin as high .

note - I have tried with SYS_INIT(); but it is not working . 

E: Device id 00 00 00 does not match config 9d 40 13
*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
I: Starting bootloader


 inside boot_read_sectors fun


*** inside flash_map_layout file inside flash area get sector


*** inside flash_map_layout file inside flash area get sector
W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?

*************** inside loader.c file ***************


********inside flash map.c crashing due to get bind **


*** inside flash map.c file inside the flash area read **
E: ***** BUS FAULT *****
E:   Instruction bus error
E: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x200002cc
E: r3/a4:  0x00000020 r12/ip:  0x0af7fbb5 r14/lr:  0x000010cf
E:  xpsr:  0x61000000
E: Faulting instruction address (r15/pc): 0x0af7fbb4
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20000210 (unknown)
E: Resetting system
E: Device id 00 00 00 does not match config 9d 40 13
*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
I: Starting bootloader

Error is - E: Device id 00 00 00 does not match config 9d 40 13

Parents
  • Hi,

    During reset the state of the IC is undefined, to there is no way to ensure that the pin is always high before booting form only SW. For that, you would need an external pull resistor to control this, and also not power the external flash directly from the GPIO (not sure if you do that, though). Without it, I guess the question is how early in the boot process you can configure the GPIO pin as an output and set it to high? It seems like you need this external flash in MCUBoot, and so doing this when the Zephyr application starts is too late. But as setting a GPIO is quite straight forward if you just use the HAL (modules/hal/nordic/nrfx/hal/nrf_gpio.h) to access the registers directly, I suggest looking into doing that early in the main function of MCUboot (bootloader/mcuboot/boot/zephyr/main.c).

Reply
  • Hi,

    During reset the state of the IC is undefined, to there is no way to ensure that the pin is always high before booting form only SW. For that, you would need an external pull resistor to control this, and also not power the external flash directly from the GPIO (not sure if you do that, though). Without it, I guess the question is how early in the boot process you can configure the GPIO pin as an output and set it to high? It seems like you need this external flash in MCUBoot, and so doing this when the Zephyr application starts is too late. But as setting a GPIO is quite straight forward if you just use the HAL (modules/hal/nordic/nrfx/hal/nrf_gpio.h) to access the registers directly, I suggest looking into doing that early in the main function of MCUboot (bootloader/mcuboot/boot/zephyr/main.c).

Children
Related