Due to high demand, expect some shipping delays at this time - orders may not ship for up to 2-3 business days.
0

RP2040 Trinkey (5056) won't accept a new code.py
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

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

by duanev on Mon Jan 17, 2022 2:00 pm

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 | TOGGLE FULL SIZE
# 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?

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

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

by dastels on Mon Jan 17, 2022 2:09 pm

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

Dave

dastels
 
Posts: 9796
Joined: Tue Oct 20, 2015 3:22 pm

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

by duanev on Mon Jan 17, 2022 3:47 pm

Code: Select all | TOGGLE FULL SIZE
# mount /dev/sdb1 /mnt/mpy
# cp /home/me/code.py /mnt/mpy
# sync
# umount /mnt/mpy
then press reset ...

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

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

by dastels on Mon Jan 17, 2022 4:41 pm

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

dastels
 
Posts: 9796
Joined: Tue Oct 20, 2015 3:22 pm

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

by duanev on Mon Jan 17, 2022 7:16 pm

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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
# 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.

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

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

by dastels on Mon Jan 17, 2022 8:20 pm

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

dastels
 
Posts: 9796
Joined: Tue Oct 20, 2015 3:22 pm

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

by duanev on Mon Jan 17, 2022 8:28 pm

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.

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

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

by dastels on Mon Jan 17, 2022 8:33 pm

So.. is it figured out?

Dave

dastels
 
Posts: 9796
Joined: Tue Oct 20, 2015 3:22 pm

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

by danhalbert on Mon Jan 17, 2022 10:46 pm

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.

danhalbert
 
Posts: 3183
Joined: Tue Aug 08, 2017 12:37 pm

Please be positive and constructive with your questions and comments.