Yes I know how it is done with the Pico-SDK, the NuttX is sort of different :-)

The fact that the ID is stored in the flash circuits and not in the processor 
seems to make it a bit tricky. 

In the file pico-sdk/src/rp2_common/hardware_flash/include/hardware/flash.h it 
is recommended to extract flash metadata during startup, to avoid potential 
problems, for example with interrupts or the second core simultaneously trying 
to execute code on the flash memory. Therefore one solution here may be to read 
out the flash id during boot and keep it in memory for later access from a user 
application. All of course if the configuration to have a unique id is enabled. 
Such a solution can be implemented in either 
nuttx/boards/arm/rp2040/raspberrypi-pico/src/rp2040_initialize.c or 
rp2040_bringup.c. Possibly in the common versions of these if the flash id 
solution is equal across all boards with the RP2040 processor. In addition to 
this, some access function would be needed in a new file rp2040_uid.c or so. 

But what is the procedure in NuttX to store some global variable in memory? 
Preferably as read-only after initialization. 

Anders





On Thursday, 14 March 2024 at 14:39, Alan C. Assis <acas...@gmail.com> wrote:

> Hi Anders,
> 
> As I said the RP2040 doesn't have a unique id like others MCUs, then the
> solution they found was read from its SPI Flash, more info:
> 
> https://github.com/raspberrypi/pico-sdk/pull/12
> 
> You need to look how they did it and use it in NuttX.
> 
> BR,
> 
> Alan
> 
> On Thu, Mar 14, 2024 at 4:09 AM Anders andyl...@proton.me.invalid wrote:
> 
> > Hello Alan and thanks for the warm welcome.
> > 
> > Yes, the id is in the flash part of the board and the code for extracting
> > the unique id is in the Pico bootrom. But how to acces and run bootrom code
> > from a Nuttx application?
> > The code for other boards seem to access an id in a processor register.
> > And while access to flash fs on the Pico supposedly could give some hints,
> > a solution still eludes me.
> > 
> > Anders
> > 
> > -------- Originalmeddelande --------
> > Den 25 feb. 2024 20:17, Alan C. Assis skrev:
> > 
> > > Hi Anders, Welcome to NuttX !!! Yes, you are right, the rp2040 port
> > > doesn't yet have support for uniqueid. If you want to add it, please enter
> > > inside nuttx/arch/arm/src/ and "git grep uniqueid" for a reference how it
> > > is done in other chips. Example in cxd56xx arch:
> > > arch/arm/src/cxd56xx/cxd56_uid.c And cxd56xx common boards:
> > > boards/arm/cxd56xx/common/src/cxd56_uid.c Notice that rp2040 doesn't have
> > > unique id like other chips, but you have use the flash serial number as
> > > unique id, more info:
> > > https://forums.raspberrypi.com/viewtopic.php?t=331910 BR, Alan On Sun,
> > > Feb 25, 2024 at 9:58 AM Anders wrote: > Having just started to play with
> > > nuttx running on Raspberry Pi Pico, I > discovered that configuring 
> > > support
> > > for the unique id functions results in > a build of nuttx that fails. My
> > > understanding is that support for this is > not currently added. One can
> > > find code for this for other boards in the > corresponding directory tree
> > > of nuttx. > > Reading in the archives of this list, it is not recommended
> > > to use > functions from the Pico-sdk. So new driver code should be added. 
> > > >
> > > What is the recommended way of adding this functionality? Adding the >
> > > interface in a separate file of boards/arm/rp2040/raspberry-pi-pico/src/ >
> > > and Make.defs seems easy. But where would the code for actually 
> > > interfacing
> > > with the flash best go? > > Anders

Reply via email to