apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.74k stars 1.14k forks source link

Nuttx not installing correctly on the Particle Photon. #6938

Closed greg5678 closed 1 year ago

greg5678 commented 2 years ago

Here are the commands I've used.

$ mkdir nuttxspace
$ cd nuttxspace
$ git clone https://github.com/apache/incubator-nuttx.git nuttx
$ git clone https://github.com/apache/incubator-nuttx-apps apps
$ cd nuttx
$ ./tools/configure.sh -l photon:wlan
$ make menuconfig

Another post said it better than I ever could. "Application Configuration → Network Utilities → Network initialization → WAPI Configuration set SSID and Passphrase corresponding to the Wi-Fi AP (Router) save, exit"

$ make
$ sudo dfu-util -d 2b04:d006 -a 0 -s 0x08020000 -D nuttx.bin

The device just continues to blink yellow and if I unplug neither the status light nor the D7 LED comes on, but I can still put the device in DFU mode (which causes it to blink yellow).

dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 2b04:d006
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x08020000, size = 345560
Download    [=========================] 100%       345560 bytes
Download done.
File downloaded successfully
acassis commented 2 years ago

Hi @greg5678 sorry I only saw your issue today. Did you search to know what the yellow blinking means? Last time I tested Particle Photon was with NuttX 8.x, I need to test it again with new version.

greg5678 commented 2 years ago

Thanks for replying, @acassis. Yes, so it blinking yellow means it's in DFU mode. I made a couple of posts about it on Particle's forum, and they recommend I downgrade it to 0.5.5, but that didn't help.

https://community.particle.io/t/unable-to-flash-nuttx-to-my-photon/63058/6 https://community.particle.io/t/how-to-downgrade-a-particle-photons-device-os-version/63062/4

greg5678 commented 2 years ago

Any idea what might be the issue?

acassis commented 2 years ago

Hi @greg5678 I did a little investigation today and it seems that some modification broke the network support:

ABCDF
netdev_register: Registered MAC: 00:00:00:00:00:00 as dev: wlan0
netdev_ifr_ioctl: cmd: 1794
netdev_ifr_ioctl: cmd: 1796
netdev_ifr_ioctl: cmd: 1800
netdev_ifr_ioctl: cmd: 1818
nsh_telnetstart: Starting the Telnet daemon
telnetd_daemon: Accepting connections on port 23

You can see it if you enable: Device Drivers -> Serial Driver Support -> Serial Console = USART1 and Build Setup -> Debug Options -> Enable Debug Features (En. Error, Warn and Info) and Network Debug Features (Error, Warn and Info).

Then use a USB/Serial 3.3V connected to TX/RX/GND pins of the board and use a serial console terminal (i.e. minicom) configured to 115200.

If you download some previous NuttX version you will see it was working, I suspect some recent modification on network generated this issue.

acassis commented 2 years ago

Ok, I found an old version that worked fine for me. It was from 2018! For some reason DHCP didn't work with my router, then I setup it fixed to 192.168.0.16. You can find my saved defconfig here: https://pastebin.com/raw/V33BnMVv If you want to test the binary, just flash it on your board and configure a wifi router (or phone with hotspot) with SSID: DLINK and password: dlinkphoto More info here: https://acassis.wordpress.com/2022/09/10/nuttx-binary-to-test-particle-photon-board/

$ telnet 192.168.0.16
Trying 192.168.0.16...
Connected to 192.168.0.16.
Escape character is '^]'.

NuttShell (NSH)
nsh> uname
NuttX
nsh> ?
help usage:  help [-v] [<cmd>]

  [           cmp         free        mb          pwd         time        
  ?           dirname     help        mkdir       rm          true        
  arp         dd          hexdump     mh          rmdir       uname       
  basename    df          ifconfig    mount       set         umount      
  break       echo        ifdown      mv          sh          unset       
  cat         exec        ifup        mw          sleep       usleep      
  cd          exit        kill        nslookup    test        xd          
  cp          false       ls          ps          telnetd     

Builtin Apps:
  wapi
nsh> 
greg5678 commented 2 years ago

So, I downloaded nuttx 8.2 and did the same thing as before, but the device just keep blinking yellow and when I pressed the reset button the device's status LED stayed dark like before. I then took the firmware you gave me and it gave me the same results. I created the Wi-Fi network, but I never saw the device appear. As the yellow light blinks the D7 led is dim which means it hasn't exited the bootloader.

from the Particle forum: "The device won’t reset when you use the DFU command to flash nuttx.bin, you’d need to manually reset the device, so that’s expected.

And are you sure nuttx isn’t running? Since it would need to manually control the status LED, it very well may not do that. And D7 doing off is a good sign. When the bootloader is running, the status LED is on dimly. It going off indicates that the bootloader exited and it probably jumped to the nuttx code."

Flashing your firmware:

$ md5sum nuttx.bin
56f9b321ca946f092e89f42723a0cea3  nuttx.bin
sudo dfu-util -d 2b04:d006 -a 0 -s 0x08020000 -D nuttx.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 2b04:d006
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x08020000, size = 336020
Download    [=========================] 100%       336020 bytes
Download done.
File downloaded successfully

Update:

Okay, after flashing Nuttx 8.2 the device seems to connect to the network, but I'm unable to connect to it via telnet and then it disappears after a minute or two.

Update 2: It works. :)

nsh> uname
NuttX
nsh> ?
help usage:  help [-v] [<cmd>]

  [         cd        echo      hexdump   mb        mw        set       true
  ?         cp        exec      ifconfig  mkdir     nslookup  sh        uname
  arp       cmp       exit      ifdown    mkrd      ps        sleep     umount
  basename  dirname   false     ifup      mh        pwd       test      unset
  break     dd        free      kill      mount     rm        telnetd   usleep
  cat       df        help      ls        mv        rmdir     time      xd

Builtin Apps:
  nsh   ping  wapi
nsh>
greg5678 commented 2 years ago

So, since the network support is broken on the newer versions of Nuttx will that get patched eventually?

acassis commented 1 year ago

@greg5678 I missed your message, probably because other priority tasks. Please refer to this issue: https://github.com/apache/nuttx/issues/8839 I got NuttX 9.0 working on Photon board. Maybe you could help too to find each patch broke it.

BTW, I will close this issue because it is duplicated now.