Radiolink AT9 as a platform for Deviation?

More
20 May 2016 07:02 #48841 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
I've got my discrete logic board today - soldered everything except the 4-in-1 module. It fits AT9 and both switch logic and SPI flash on it seem to be working - I successfully read device id from flash.

Now we need to solve the problem of multiplexing both flash and radio on the same SPI and this solution is going to work. It will also work for flash-impaired F4/F7.

Please Log in or Create an account to join the conversation.

More
20 May 2016 12:53 #48861 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
nice. the main issue is that we read flash in the main code context but all protocol code executes in interrupt context.which means an interrupt can happen in the middle of an spi transfer (i think the transfer itself is atomic, but the setting of the chip-select is certainly not).
Possible options:
1) place all spi handling code in an interrupt that has higher priority than either the main code or protocol code
2) disable interrupts while executing spi code
3) use a queue (and probably DMA) to stage requests (along with the csn controls) to serialize requests

1 and 2 are almost the same thing when it comes down to it. The main question is what is the average length of a memory read, and will it affect protocol timing? Memory access is generally less critical than the protocol code. we could use byte-level memory reads when using the module (no high-speed transfers) and set/clear the csn for each byte. that would make the time spent in a critical section pretty low.

3 is a cool idea as it would allow a central code stream to handle all spi with minimal critical sections (just the command staging), but is a lot more complicated to setup.

Honestly, the easiest thing to do is to just disable interrupts when csn is low and re-enable them when it is high in the spi_flash code, and see what happens.

Please Log in or Create an account to join the conversation.

More
20 May 2016 13:01 #48863 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
By the way, the at9 enabling has led me down a rabbit hole..After redoing the 320x240 menu system and rewriting the scroll handling, I'm now rewriting all the code to get rid of the listbox widget (replacing it with a scrollable, should be nearly transparent) because the listbox doesn't play well with the 4-button model. Hopefully that will be the last of the major gui changes, and i'll be able to start working on fixing the buttons and whatever else. This has been a lot more work than I expected, but the GUI code will be in a more supportable state in the end I hope. A lot of cruft has seeped in over time, and it is about time for a good spring cleaning. As mentioned in the 'post 5.0' thread, this also means it will take some time to shake out all the new bugs though.

Please Log in or Create an account to join the conversation.

More
20 May 2016 22:01 #48907 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
I can see the mentioned rabbit hole, but I think it is useful in a larger scheme of things.

Regarding SPI multiplexing - I think we can arrange long SPI operations in time. You always know the time to the next protocol interrupt, so having a long operation at hand you can decide to wait over till the next time slot and you can make sure it will be integral by disabling interrupts. The chances that it will mess with protocol timing will be small if we wait first. The most frequent protocols have inactivity periods of at least 2ms, should be enough for complete SPI operation.

Staging requests in a queue probably will not work well - sometimes you need to read something from the radio and decide what to do next upon it. May be it's easier to make the time sharing a little less real time by executing protocol code not in an interrupt but in a main process by context switch. You either switch immediately if you have no SPI operation pending or after current SPI operation completes. It requires some scheduler, but should not be that complex.

Please Log in or Create an account to join the conversation.

More
21 May 2016 01:31 #48912 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
I don't like the idea of a scheduler for this. It is a lot of complexity. I'm also really concerned with trying to guess when a protocol may need to do work. That can be difficult given the the protocols reschedule themselves.
i think a queue may actually work fine. the main question is: is the SPI transfer long enough that it affects the timing of the protocol. if we keep memory transfers short, I think the answer will be no.

I agree that the GUI work is beneficial. I could have hacked something that would work, but this revamp is long overdue and makes the code a lot easier to work on. It is also having the effect of freeing up quite a bit of space on the 7e/f7

Please Log in or Create an account to join the conversation.

More
21 May 2016 04:40 #48927 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
I'm not talking about relying on such guess, just as an optimization strategy. For adesto AT25DF161 (probably typical) 256byte page is written in 1ms, 4K sector erased in 50ms. So I think just disabling interrupts for the period of CS low can be enough.

Please Log in or Create an account to join the conversation.

More
21 May 2016 04:41 #48928 by FDR
Don't forget about receiving telemetry data! That inducates SPI traffic too, doesn't it? Furthermore it does it in a more unpredictable way according to timing...

Please Log in or Create an account to join the conversation.

More
21 May 2016 04:44 #48930 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
Actually, no, not more unpredictable. We don't use RF chips' IRQ, we query them whether they have a packet received. So we do this at our schedule.

Please Log in or Create an account to join the conversation.

More
21 May 2016 04:53 #48931 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
you do not need to hold csn low while erasing pages (or writing them). the real question is how fast can the spi clock run (probably the slowest of the protocol chips) and what is the hold time for clearing and setting csn. There really shouldn't be a significant penalty to write a byte at a time (or maybe a small buffer at a time depending on delay). We could also switch the spi frequency on entering/leaving the interrupt so that we can run the spi at high frequencies for the flash.

The SST25VF032B can run at 80MHz with a 5ns setup/hold. That is plenty fast. We can ignore the setup/hold altgether with that chip. We'd probably want to have a transfer size of > 10bytes to minimize the overhead of setting the address, but otherwise, it should be fine to just disable interrupts during memory access. I don't recall which chip you were using, but I think it had similar specs.

Please Log in or Create an account to join the conversation.

More
21 May 2016 04:54 #48933 by FDR
OK, thanks for clarification!

Please Log in or Create an account to join the conversation.

More
21 May 2016 21:16 - 21 May 2016 21:18 #48983 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
At DIV4 256 bytes would take 100us to transfer. Command to erase a page takes under 1us. I doubt we need to keep clock to the slowest chip - as long as CS inactive it should not affect them. I'd switch to fast clock for flash, to slow (DIV16) for RF. And I understand you don't need to hold CS for waiting for completion.
Last edit: 21 May 2016 21:18 by victzh.

Please Log in or Create an account to join the conversation.

More
22 May 2016 02:26 #48994 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
why not use DIV/2? Is that too fast for the memory you're using?

Please Log in or Create an account to join the conversation.

More
22 May 2016 18:09 #49028 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
I'll try, it should be OK. Modern flash memories rarely have clock speed less than 54MHz.

Please Log in or Create an account to join the conversation.

More
24 May 2016 05:03 #49105 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
Check in 95758e0 "Add support for multiple file descriptors to devofs" breaks the system. Fonts can not be loaded - every dialog, menu etc. are blind.

Please Log in or Create an account to join the conversation.

More
25 May 2016 02:06 #49158 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
It is fixed now. I also reworked the filesystem code so that it is possible to build the emulator to use the filesystem image (which makes it easier to debug filesystem related issues). This is disabled by default.

Please Log in or Create an account to join the conversation.

More
25 May 2016 20:36 #49221 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
Thanks, I wanted to evaluate current menu system on a real device.

Please Log in or Create an account to join the conversation.

More
26 May 2016 01:17 #49246 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
I just updated the chantest page. As far as I know all pages except the model layout are now fully accessible. I am thinking of remapping the 'mode' button so that if it is pressed, the scroll wheel acts as left/right rather than up/down. That would provide a solution for the model_layout page which I have otherwise not been able to figure out a solution to.

I fixed the channels as well I think, though my testing was limited.

Please Log in or Create an account to join the conversation.

More
26 May 2016 12:39 #49282 by victzh
Replied by victzh on topic Radiolink AT9 as a platform for Deviation?
I implemented basic support for SPI flash on my board and recompiled in Devo 8 mode - I have full color on at9 now! And I spent 2 hours debugging missing CS_HI - when I found it I felt totally stupid. Support for radio is next.

You fixed the channels as far as I can tell. There are couple more problems beyond model layout page. First is keyboards. Second is encoder interpretation as a couple of buttons is imperfect - sometimes buttons stuck preventing all other buttons to work, sometimes in fast movement in one direction it interprets it as movement in another.

Please Log in or Create an account to join the conversation.

More
26 May 2016 12:44 #49283 by PhracturedBlue
Replied by PhracturedBlue on topic Radiolink AT9 as a platform for Deviation?
I think we probably need an interrupt handler for the wheel. I haven't looked into it yet though.

Please Log in or Create an account to join the conversation.

More
26 May 2016 18:17 #49304 by anasm2010
Replied by anasm2010 on topic Radiolink AT9 as a platform for Deviation?
Hey,
Thank you for your work Guys.
Do you think Is it possible to add a speaker to the AT9 or to replace the integrated buzzer ? (ofc if it's possible to add memory) That he can be used like the one on Taranis radio?

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum