Skip to content

Refine iMX RT memory layout and add three boards #2532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 27, 2020

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Jan 18, 2020

Introduces a way to place CircuitPython code and data into
tightly coupled memory (TCM) which is accessible by the CPU in a
single cycle. It also frees up room in the corresponding cache for
intermittent data. Loading from external flash is slow!

The data cache is also now enabled.

Adds support for the iMX RT 1021 chip. Adds three new boards:

  • iMX RT 1020 EVK
  • iMX RT 1060 EVK
  • Teensy 4.0

Related to #2492, #2472 and #2477. Fixes #2475.

Introduces a way to place CircuitPython code and data into
tightly coupled memory (TCM) which is accessible by the CPU in a
single cycle. It also frees up room in the corresponding cache for
intermittent data. Loading from external flash is slow!

The data cache is also now enabled.

Adds support for the iMX RT 1021 chip. Adds three new boards:
* iMX RT 1020 EVK
* iMX RT 1060 EVK
* Teensy 4.0

Related to micropython#2492, micropython#2472 and micropython#2477. Fixes micropython#2475.
@tannewt tannewt added enhancement mimxrt10xx iMX RT based boards such as Teensy 4.x labels Jan 18, 2020
@tannewt tannewt added this to the 6.0.0 milestone Jan 18, 2020
@tannewt tannewt requested a review from arturo182 January 18, 2020 01:37
@tannewt
Copy link
Member Author

tannewt commented Jan 18, 2020

Please don't merge. Teensy doesn't work. The 1060 EVK does though. :-/

@arturo182
Copy link
Collaborator

Have you tested this with the uf2 bootloader?

On power up the FlexRAM banks are in an unknown config so we can't
rely on the stack until after we configure FlexRAM.
Copy link
Collaborator

@arturo182 arturo182 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like for you to confirm that you tested this with the uf2 bootloader so my Feather's don't suddenly stop working 😅

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 19, 2020

@tannewt Just for fun, I downloaded and tried this PR on a Teensy4.0 -- using teensy_loader_cli
works!

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-beta.3-69-g1c3960634 on 2020-01-19; Teensy 4.0 with IMXRT1062DVJ6A
>>> help('modules')
__main__          busio             microcontroller   struct
_os               collections       micropython       supervisor
_pixelbuf         digitalio         neopixel_write    sys
_time             errno             os                time
analogio          gamepad           pulseio           touchio
array             gc                random            usb_hid
bitbangio         io                re                usb_midi
board             json              rtc
builtins          math              storage
Plus any modules on the filesystem
>>> 
>>> import board
>>> dir(board)
['__class__', 'A0', 'A1', 'A10', 'A11', 'A12', 'A13', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'CLK', 'CMD', 'D0', 'D1', 'D10', 'D11', 'D12', 'D13', 'D14', 'D15', 'D16', 'D17', 'D18', 'D19', 'D2', 'D20', 'D21', 'D22', 'D23', 'D24', 'D25', 'D26', 'D27', 'D28', 'D29', 'D3', 'D30', 'D31', 'D32', 'D33', 'D34', 'D35', 'D36', 'D37', 'D38', 'D39', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'DAT0', 'DAT1', 'DAT2', 'DAT3', 'I2C', 'MISO', 'MOSI', 'RX', 'RX1', 'SCK', 'SCL', 'SCL0', 'SDA', 'SDA0', 'SPI', 'TX', 'TX1', 'UART']
>>> 

One little quirk so far. After soft reboot (and possibly at other times) the first character typed into the REPL is missed (or misinterpreted)

edited to add: this is a real issue. I'm not that bad a typist. The first character its often missed , and others appear to be missed on occasion. I have not established a reproducible case yet other than than after a soft reboot (most of the time) . It also seem to be waiting for an extra carriage return at the start of the REPL (sometimes). At least that seems to help when it is misbehaving.

I was able to blink the D13 LED ! woohoo!

I also noted that the reported size of CIRCUITPY is 1Mbyte -- is this correct? expected 2.

Filesystem      1K-blocks      Used  Available Use% Mounted on
udev              4013572         0    4013572   0% /dev
tmpfs              807196      1804     805392   1% /run
/dev/sda2       952625076 155561728  748649756  18% /
tmpfs             4035964     68896    3967068   2% /dev/shm
tmpfs                5120         4       5116   1% /run/lock
tmpfs             4035964         0    4035964   0% /sys/fs/cgroup
/dev/sda1          523248      6232     517016   2% /boot/efi
tmpfs              807192        20     807172   1% /run/user/123
tmpfs              807192        72     807120   1% /run/user/1000
/dev/sdb1      3845578572 551596068 3098615244  16% /media/jerryneedell/Backups
/dev/sdc1            1001         2        999   1% /media/jerryneedell/CIRCUITPY

also


Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Hello World!



Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-beta.3-69-g1c3960634 on 2020-01-19; Teensy 4.0 with IMXRT1062DVJ6A
>>> 
>>> import os
>>> os.statvfs("/")
(512, 512, 2001, 1996, 1996, 0, 0, 0, 0, 255)
>>> 

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 19, 2020

FYI-- I tried using an I2C device but am getting errors reading the library from the Flash


Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-beta.3-69-g1c3960634 on 2020-01-19; Teensy 4.0 with IMXRT1062DVJ6A
>>> 
>>> 
>>> import msa301_simpletest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "msa301_simpletest.py", line 4, in <module>
  File "/lib/adafruit_msa301.py", line 54
SyntaxError: invalid syntax
>>> 

reading the file -- I don't see any issues with the syntax.
I tried using .mpy files, but then got a "corrupt .mpy" error.

Is reading from the Flash still a WIP?

I am able to write a simple "blink.py" to the Flash and execute it. Just wondering if the issue is with larger files

the error occurs at 0x800 bytes into the .py file (a suspiciously nice round number ;-)
here is line 54

     53 from adafruit_register.i2c_struct import ROUnaryStruct
     54 from adafruit_register.i2c_bit import RWBit
     55 from adafruit_register.i2c_bits import RWBits, ROBit

dump from od


0007c0    7469    725f    6765    7369    6574    2e72    3269    5f63
         i   t   _   r   e   g   i   s   t   e   r   .   i   2   c   _
0007d0    7473    7572    7463    6920    706d    726f    2074    4f52
         s   t   r   u   c   t       i   m   p   o   r   t       R   O
0007e0    6e55    7261    5379    7274    6375    0d74    660a    6f72
         U   n   a   r   y   S   t   r   u   c   t  \r  \n   f   r   o
0007f0    206d    6461    6661    7572    7469    725f    6765    7369
         m       a   d   a   f   r   u   i   t   _   r   e   g   i   s
000800    6574    2e72    3269    5f63    6962    2074    6d69    6f70
         t   e   r   .   i   2   c   _   b   i   t       i   m   p   o
000810    7472    5220    4257    7469    0a0d    7266    6d6f    6120
         r   t       R   W   B   i   t  \r  \n   f   r   o   m       a

@tannewt tannewt mentioned this pull request Jan 21, 2020
@tannewt
Copy link
Member Author

tannewt commented Jan 21, 2020

@jerryneedell I have a feeling its related to enabling the DCache. I think I'll disable it for now.

@arturo182 I hear ya about testing with UF2. I just haven't gotten the time to do it. Will ping when this is ready for another look.

I also need to update the USB PIDs before committing.

@tannewt
Copy link
Member Author

tannewt commented Jan 22, 2020

@arturo182 I wasn't able to get the UF2 bootloader going on my 1010 EVK. I tried to load the feather_mimxrt1011 version from commit 8d7dffe16901833041e75c3e3b6874e490cc4e6b but wasn't able to double tap reset. Is there another spot I should look? It didn't look like TinyUF2 had everything.

@jerryneedell This disables the DCache. Let me know if it fixes your issues on Teensy 4.

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 22, 2020

@arturo182 I wasn't able to get the UF2 bootloader going on my 1010 EVK. I tried to load the feather_mimxrt1011 version from commit 8d7dffe16901833041e75c3e3b6874e490cc4e6b but wasn't able to double tap reset. Is there another spot I should look? It didn't look like TinyUF2 had everything.

@jerryneedell This disables the DCache. Let me know if it fixes your issues on Teensy 4.

@tannewt -- this appears to have worked!! I can read the library files now -- I2C test worked with msa301 accelerometer.
In addition, the REPL issue seems to have been fixed as well.
New issue
Attempting to cut/paste into the REPL caused the board to crash ---REPL disconnected an CIRCUITPU dismounted -- The board appears to have got into the bootloader

  • red light on --flickering
    dmesg report
[691147.332891] FAT-fs (sdc1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[691463.089514] usb 3-2.4: USB disconnect, device number 112
[691463.631944] usb 3-2.4: new high-speed USB device number 113 using xhci_hcd
[691463.832346] usb 3-2.4: New USB device found, idVendor=16c0, idProduct=0478
[691463.832347] usb 3-2.4: New USB device strings: Mfr=0, Product=0, SerialNumber=1
[691463.832349] usb 3-2.4: SerialNumber: 000A7F32
[691463.833020] hid-generic 0003:16C0:0478.0038: hidraw1: USB HID v1.11 Device [HID 16c0:0478] on usb-0000:00:14.0-2.4/input0

It recovers OK after a power cycle

Also tested a NeoPixel Jewel -- Wow between pixelbuf and the speed of the Teensy, the
"colorwheel" really goes fast!! -- it went fast on a feather m4 as well so now probalbly running at "full" speed as controlled by the coed instead of limited by the CPU...
There is an issue with controlling pixel[0] -- writing a 0 to pixel[0] results in it being green.
This happened on both the 7 pixel jewel and a 16 pixel ring.
Tested on 2 different pins D21 and D3 -- same behavior.
Just t be sure, I verified that this does not occur on the feather M4 so it appears to be teeny40 related.

@jerryneedell
Copy link
Collaborator

regarding the REPL crash on cut/paste, I found that:

from digitalio import *
from board import *
import neopixel

works OK
but

from digitalio import *
from board import *
import neopixel
import time 

causes it to crash into bootloader mode

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 22, 2020

The Flash file system on the Teensy4.0 is also still showing up as only 1Mbyte - is this expected?

@tannewt
Copy link
Member Author

tannewt commented Jan 22, 2020

@jerryneedell Thanks! I'll try and check out that crash soon. I'm glad it is working better.

The 1MB filesystem is correct. We use the first 1MB of external flash for the bootloader and CircuitPython. The Teensy has a 2MB flash which leaves 1MB for the filesystem. @arturo182's feathers have 8MB so the filesystem will be 7MB.

@arturo182
Copy link
Collaborator

@tannewt I don't think I'll have time to look at the uf2 issue until Saturday or Sunday, sorry. You could maybe try tinyuf2, the tinyusb branch was just a proof of concept, but it was working on my Feathers (and still is, haven't flashed it since the original flash).

@tannewt
Copy link
Member Author

tannewt commented Jan 27, 2020

@arturo182 Mind if I merge this? I know it's not perfect but I'd like to get it in so it doesn't grow stale. I'll happily follow up with changes to work with the bootloader and other fixes.

@arturo182
Copy link
Collaborator

I guess it's fine, even though I haven't had time to test it yet. The Adafruit Feather boards were delayed a week, so I will test this when I'm bringing them up later.

@tannewt
Copy link
Member Author

tannewt commented Jan 27, 2020

Ok, thanks! Let me know what needs to be fixed. I'll try to get a feather from @ladyada when she has some.

@tannewt tannewt merged commit b36b249 into adafruit:master Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement mimxrt10xx iMX RT based boards such as Teensy 4.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mimxrt10xx: Try to get all the RAM banks working
3 participants