RP2040 Trinkey (5056) won't accept a new code.py

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
duanev
 
Posts: 13
Joined: Fri Mar 02, 2018 11:45 am

RP2040 Trinkey (5056) won't accept a new code.py

Post by duanev »

Plugged in the Trinkey rp2040 with bootsel pressed, mounted the partition, and installed the uf2. Resetting the board spits Hello World! out the /dev/ttyACM1 device (I have another pink rp2040 running on /dev/ttyACM0). Mounting the Trinkey filesystem again shows the boot_out.txt log:

Code: Select all

# cat /mnt/mpy/boot_out.txt 
Adafruit CircuitPython 7.1.0 on 2021-12-28; Adafruit Feather RP2040 with rp2040
Board ID:adafruit_feather_rp2040
but when I write code.py to the filesystem and reset the board, the default code.py(?) runs instead, and if I remount the bootsel again I see my code.py has been replaced with the "Hello World!" default. Am I missing something?

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by dastels »

It doesn't sound like you're actually writing a new code.py to the board. How are you trying to do that?

Dave

User avatar
duanev
 
Posts: 13
Joined: Fri Mar 02, 2018 11:45 am

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by duanev »

Code: Select all

# mount /dev/sdb1 /mnt/mpy
# cp /home/me/code.py /mnt/mpy
# sync
# umount /mnt/mpy
then press reset ...

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by dastels »

Doesn't it automatically mount as CIRCUITPY when you plug it in? Have you read the CircuitPython pages in the Trinkey QT2040 guide? https://learn.adafruit.com/adafruit-trinkey-qt2040

Dave

User avatar
duanev
 
Posts: 13
Joined: Fri Mar 02, 2018 11:45 am

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by duanev »

Not on my operating system. I don't run huge desktop UIs with all those bells and whistles.

I ran some more tests. `code.py` appears in the current directory when circuitpython runs (ie. when bootsel is not present), but it contains the 'Hello World!' print() and it cannot be overwritten:

Code: Select all

Adafruit CircuitPython 7.1.0 on 2021-12-28; Adafruit Feather RP2040 with rp2040                                         
>>> with open('code.py', 'w') as fh:
...     fh.write('print("hi there")\n')
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 30] Read-only filesystem
>>>
which is not surprising.

What is is that when bootsel IS mounted and written to, there are no errors, and any changes do not survive umount/remount:

Code: Select all

# ls -l /mnt/mpy/
total 8
-r-xr-xr-x 1 root root 241 Sep  5  2008 INDEX.HTM
-r-xr-xr-x 1 root root  62 Sep  5  2008 INFO_UF2.TXT
[root@archdt ~]# echo "print('hi there')" > /mnt/mpy/code.py
[root@archdt ~]# ls -l /mnt/mpy/
total 12
-rwxr-xr-x 1 root root  16 Jan 17 17:07 code.py
-r-xr-xr-x 1 root root 241 Sep  5  2008 INDEX.HTM
-r-xr-xr-x 1 root root  62 Sep  5  2008 INFO_UF2.TXT
[root@archdt ~]# umount /mnt/mpy
[root@archdt ~]# mount /dev/sdb1 /mnt/mpy
[root@archdt ~]# ls -l /mnt/mpy/
total 8
-r-xr-xr-x 1 root root 241 Sep  5  2008 INDEX.HTM
-r-xr-xr-x 1 root root  62 Sep  5  2008 INFO_UF2.TXT
[root@archdt ~]# 
So the code.py that prints 'Hello World!' is some CircuitPython default that runs when bootsel does not contain a code.py file.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by dastels »

Seeing INDEX.HTM and INFO_UF2.TXT makes me thing the board is mounting in bootloader mode which explains some of what you're seeing.

Dave

User avatar
duanev
 
Posts: 13
Joined: Fri Mar 02, 2018 11:45 am

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by duanev »

Oh, interesting!

When I remove the OTHER rp2040 (the pink feather), then the Trinkey starts working properly.

I don't see how this can be a CircuitPython problem ...

(an hour later)

Yes Dave, the BOOTSEL button should not be used for CircuitPython, it is used only to install a new uf2. Once CircuitPython is running there is also a mountable partition that is available all the time, into which we can write code.py, libs, etc., and then we can enter ctrl-d on the serial device (the CircuitPython console) to cause code.py to be executed (dropping back into CircuitPython's command interpreter when code.py stops or fails or we interrupt it).

The RP2 drive that appears when BOOTSEL is held and the board reset or powered up, deliberately gets reset to only the INDEX and INFO files ... but that's an RP2 thing.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by dastels »

So.. is it figured out?

Dave

User avatar
danhalbert
 
Posts: 4654
Joined: Tue Aug 08, 2017 12:37 pm

Re: RP2040 Trinkey (5056) won't accept a new code.py

Post by danhalbert »

The RPI-RP2 drive is a fake drive that is used only for updating the firmware, such as updating CircuitPython, or uploading a new Arduino program. But when CircuitPython is running, you will see the CIRCUITPY drive, which is real.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”