-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
mimxrt: Five small service type changes. #9137
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
Conversation
robert-hh
commented
Aug 29, 2022
•
edited
Loading
edited
- Remove a few commented code lines from machine_uart.c
- Change the header of the load image to match the new teensy loader, which does not erase the file system any more, given that the header version is 4.3 and the final binary size is properly set in the header. The new Teensy loader will be installed at the device is any sketch is loaded to the Teensy device using the up-to-date teensyduino package. This change would not be needed to keep the file system if mimxrt/mboot: Adds bootloader support. #8229 was merged, which is the better solution as being uniform for all boards.
- Alllow the keyword option cs=-1 for the machine SPI class. In that case, the hardware CS pin will not be controlled by the SPI controller, but has to be set by the application. That allows for arbitrary pins being used for cs.
- Set the uart ioctl write poll flag properly. It now will be set when the send buffer is empty. Before, it always returned that writing is possible.
- Fix a regression bug in uart.write() causing data to be sent incomplete.
The new teensy loader keeps the file system under certain conditions: - The file size is properly set in the file header. - The header version is 4.3 These changes are implemented here, requiring a backport of fsl_flexspi_nor_boot.c. There is still a problem with the command line version of the teensy loader, which fails on the first attempt. At the second attempt it works. The GUI version of the teensy loader is fine.
In that case, no Pin will be configured for the CS signal, even if it is internally still generated. That setting allows to use any pin for CS, which then must be controlled by the Python script.
It was always set to True. The change adds a check to the tx status flag which is set when all data is transferred.
d188f17
to
46565d0
Compare
@dpgeorge The recent commit contains the changes you suggested. While looking at the machine_uart.c code and having the discussion #9187 in mind, I noticed that the timeout handling in uart.write() is different. It does not care for the timeout set at the object, but calculates a timeout from the data size and the transfer speed. To make it consistent, that should be changed. So I'll make another commit in this PR. |
Causing an incomplete send if the data size was longer than the buffer size.
46565d0
to
e435583
Compare
Changing the timeout mechanism requires a complete rework of uart.write, to work with ring buffers. So for now I just added a bug fix. That bug causes data to be sent incomplete, if the data size was larger than the buffer size. I'm pretty sure that I tested this case before, but there was a change in the library version. |
@dpgeorge About discussion https://github.com/orgs/micropython/discussions/9187, I could add a check in uart.write(), that in case the timeout is set to 0 and the data cannot be delivered immediatly, it returns a timeout error with 0 data being delivered. Would that properly interact with the stream writer mechanism? |
Definitely the UART should support non-blocking mode, which is selected by |
I implemented as a test a method which checks, if the data can be sent without blocking for longer than the set timeout, which can be 0. And yes, both rp2 and STM32 set |
@dpgeorge One question: if let's say: |
It should be (b). That's how TCP sockets work, and why |
40d6c27
to
302f8dd
Compare
@robert-hh let me know when this is ready to review. |
I usually push things only when they are ready to review, especially for branches where I already made a PR. For the latter ones I mostly make commits to keep them compatible with the evolving master branch. In this actual PR I was anxious that you would have merged it already, because I'm not happy with the last commit. I works as intended, but the code style is nasty. So i can have another look at it now. |
302f8dd
to
50f8566
Compare
@dpgeorge It's ready now. I could not do much about it that removing one obsolete variable and renaming another one. And adding a few more comments. I have a similar change already for rp2, but that one simplifies the existing code (based on the SAMD PR). But instead of making a PR for every port, I will go through the other ports and see, If I can make a similar change there and have a combined PR, like the uart.flush() series. I already noticed that the ESP32 call for uart_write_bytes() does not work as documented. The documentation tells that the call does NOT block, but it does, and the code is implemented as blocking. |
297a702
to
e435583
Compare
Hello @dpgeorge I removed the last commit and placed it into another PR candidate, which addresses the UART write timeout for various boards. That's more consistent. |
If you want to put the PR on hold, convert it to a draft (there is a setting somewhere on the PR page to do that). |
This one sets the flash imange length properly for the teensy loader, such that the file system is not erased. It was already set in PR micropython#9137, but got lost when the MIMXRT1176 board was added. Signed-off-by: robert-hh <robert@hammelrath.com>
…gin-limitations document Espressif AnalogIn limitations