wiced_adc_init() failed in bootloader

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

Our project uses WICED SDK 3.1.2 and the Inventek board  ISM43362_M3G_L44(The BCM943362WCD4 and ISM43362_M3G_L44 modules are identical modules. Both uses the STM32F205 as host MCU and same BCM43362 WiFi radio). We want to use ADC 3 [WICED_GPIO_4}/GPIOA3 pin for factory reset button. wiced_adc_init()  always fails in main() of WICED-SDK\apps\waf\bootloader. But wiced_adc_init() is ok in void application_start( ).  Is there any configuration missing for wiced_adc_init() in bootloader main()?

Thanks

0 Likes
5 Replies
Anonymous
Not applicable

Hi,

Our project was stuck in the issue above.  We need your urgent help.

In addition, is there a minimal example of implementing a simple getchar() / putchar() in the bootloader?

Regards,

0 Likes
Anonymous
Not applicable

Hi,

We are trying to use the  ADC 3 [WICED_GPIO_4}/GPIOA3 pin for factory reset button. Below is the code implementation  in platform_check_factory_reset( void )

#define KEYADC WICED_ADC_3

/* Checks if a factory reset is requested */

wiced_bool_t platform_check_factory_reset( void )

{

    wiced_bool_t wiced_bool;

    uint16_t key_value = 0;

   wiced_adc_init(KEYADC, 10);

   wiced_adc_take_sample(KEYADC, &key_value);

     if( (key_value) >= (2033) )

     {

                    /* Factory reset button is being pressed. */

                    return WICED_TRUE;

      }

     return WICED_FALSE;

}

When I press the factory_reset button, the key_value above should be >=2033, but its value always 31~40. The platform_check_factory_reset() always return WICED_FALSE. But I put those statement above in the 

void application_start( ), it works perfectly. We need the urgent help to resolve the issue.

In addition, how to debug the bootloader code? is there a minimal example of implementing a simple getchar() / putchar() in the bootloader? Can I make target "snip.hello_feng-ISM43362_M3G_L44-debug download" and set the breakpoints in platform_check_factory_reset()?

Thanks,

0 Likes
Anonymous
Not applicable

Hi,

I didn't dig deep in to this, but the short answer is, the boot loader isn't meant to have any of these. Boot loaders are designed to do minimum functionality of booting an application. Trying to enable ADC and UART communication (which are not by default) means increase the size of the boot loader (over the limited size given to it) and wasn't supported.

Is there a particular reason you want to USE ADC rather than the GPIO just for the booting? Also using ADC for factory reset sounds dangerous to me.

Regards,

Bassem

Anonymous
Not applicable

Hi Bassem,

We don't have a specific gpio pin for the factory reset button on our board. So we try to use a gpio pin for ADC function. In this way we may have three buttons(that correspond to high/medium/low sampling voltage level) on the one adc pin.  

How to debug the bootloader code? is there a minimal example of implementing a simple getchar() / putchar() in the bootloader? Can I make target "snip.hello_feng-ISM43362_M3G_L44-debug download" and set the breakpoints in platform_check_factory_reset()?


Thanks

0 Likes
Anonymous
Not applicable

Hi,

I don't assume you need the three buttons in the boot loader. So why not configure it as GPIO in the plaform_check_factory_reset (as this is called only from the boot loader) and when application start configure it as a ADC to correspond to 3 buttons.

Debugging the boot loader is exactly the same as debugging and application. The boot loader is produced in a different folder usually called build/waf_bootloader-NoOS-NoNS-XXX where XXX is your platform. The elf file is in the binary folder, set your debugger to this elf file and you should be able to debug it as normal.

Regarding putchar and getchar, you will notice that in platform_init_external_devices the platform_stdio_init (which enables UART) is wrapped in the a #ifndef WICEC_DISABLE_STDIO this flag is enabled for boot loader, so boot loader doesn't support printing to UART by default.

As you notice we are making the boot loader as minimal as possible, so try to keep its job just for boot loading.

Regards,

Bassem