mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Circle - C++ bare metal environment (with USB)

Tue Dec 09, 2014 5:21 pm

How to make USB interrupts sent to the VC4?
(in Freeblob, the ARM core is power-gated off, so it just crashes) :(

Sniper435
Posts: 24
Joined: Fri Nov 02, 2012 1:35 pm

Re: Circle - C++ bare metal environment (with USB)

Sat Jan 03, 2015 10:57 pm

Been trying to make some simple programs work but seem to be hitting a problem when initialising my CTimer object - execution just stops when I get the the command "m_Timer.Initialize()". been over and over the examples but can't find the problem.

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Sun Jan 04, 2015 7:48 pm

Sniper435 wrote:Been trying to make some simple programs work but seem to be hitting a problem when initialising my CTimer object - execution just stops when I get the the command "m_Timer.Initialize()". been over and over the examples but can't find the problem.
The problem was sorted out using Email. The lesson from it is: Even if you do not have a display attached to a system using Circle do not remove the CLogger member and the logging device (CScreenDevice or CSerialDevice) from CKernel because there may be logging messages generated which may crash the system otherwise.

Sniper435
Posts: 24
Joined: Fri Nov 02, 2012 1:35 pm

Re: Circle - C++ bare metal environment (with USB)

Mon Jan 05, 2015 2:46 pm

as rst mentioned my problems have been solved - thanks to some help.
I would like to add though that in testing I found that while my code worked fine with the ScreenDevice and Logger present and a HDMI screen plugged in, it didn't seem to work when the HDMI screen was removed.
Due to specifics of my application there wont be a screen and the pins used for the serialdevice are also unavailable, to get around the problems of the logger needing a device to log to I used a CDevice object instead which seems to work just find as a dummy device for the logger to send messages into oblivion.
My next trick is going to be getting i2c up and running - if I succeed then I'll be happy to contribute back to the library any i2c code for you to incorporate.

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Mon Jan 05, 2015 5:48 pm

Sniper435 wrote:I used a CDevice object instead which seems to work just find as a dummy device for the logger to send messages into oblivion.
Good idea to use CDevice as a "null device" in this case.
My next trick is going to be getting i2c up and running - if I succeed then I'll be happy to contribute back to the library any i2c code for you to incorporate.
I2C is an interesting topic. Please let me know when you have code for it to contribute.

Sniper435
Posts: 24
Joined: Fri Nov 02, 2012 1:35 pm

Re: Circle - C++ bare metal environment (with USB)

Tue Jan 06, 2015 9:41 am

One other thing I'd be interested in, and I don't know whether you have plans for, is access to the SD card as one thing I'm hoping to achieve is a USB update system which will allow me to update the software via a USB drive. I see you've already got some code for accessing FAT file systems on USB which should allow me to handle one half part of the update but unless I'm wrong there's no capability at the moment to access the SD card?
also if there was access to the SD card would it be possible to replace the kernel.img while the pi is running?

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Tue Jan 06, 2015 3:09 pm

Currently there are no plans for a SD card driver. If such a driver would be available it should be possible to overwrite the kernel.img file on a running Raspberry Pi for a firmware update.

Sniper435
Posts: 24
Joined: Fri Nov 02, 2012 1:35 pm

Re: Circle - C++ bare metal environment (with USB)

Tue Jan 06, 2015 3:11 pm

OK, I'll tackle that one when I get to it then and if suitable feed any code back to you. having done a little research it seems that a few people have managed to get access to the SD card via the eMMC so I'm hopeful I'll be able to work it out.

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Tue Jan 06, 2015 4:28 pm

Sniper435 wrote:OK, I'll tackle that one when I get to it then and if suitable feed any code back to you. having done a little research it seems that a few people have managed to get access to the SD card via the eMMC so I'm hopeful I'll be able to work it out.
Let me know. Good luck!

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Sun Feb 15, 2015 4:14 pm

Circle was ported to the Raspberry Pi 2: https://github.com/rsta2/circle
Define "RASPPI = 2" in Rules.mk or Config.mk to use it.

Sniper435
Posts: 24
Joined: Fri Nov 02, 2012 1:35 pm

Re: Circle - C++ bare metal environment (with USB)

Fri May 22, 2015 9:15 am

Just thought I'd let you know, I am still very interested in using circle on the PI but my work on it is on hold for a short while.
One thing I'd be interested in getting into when I pick it up again is using it on the compute module, do you foresee any problems using circle on the computer module as is?

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Fri May 22, 2015 9:59 am

Sniper435 wrote:One thing I'd be interested in getting into when I pick it up again is using it on the compute module, do you foresee any problems using circle on the computer module as is?
I do not know why Circle should not run on the Compute Module but this is not tested because I do not have one.

jum
Posts: 19
Joined: Wed Mar 20, 2013 12:18 pm

Re: Circle - C++ bare metal environment (with USB)

Tue Sep 22, 2015 7:23 pm

First of all, thanks for this great work :)

I want to share how I managed to build Circle on the Raspberry Pi (in case other people are also trying to do this). The reason you might want to do this is because you want to write and build Circle apps on your RPi, rather than installing a cross-compiler on Linux or Windows laptop/PC. It only took me about 2 hours of fun fiddling to get it working:

1. Get Circle source code from github:
git clone https://github.com/rsta2/circle

2. Install "arm-none-eabi-gcc" toolchain (by default Raspian has arm-somethingelse toolchain):
Follow the intructions on page https://github.com/ARMinARM/arminarm
Actually just these instructions:
mkdir arminarm
git clone https://github.com/ARMinARM/arminarm
cd arminarm
./setup
In setup, choose option 1 (update/install arminarm gcc toolchain)
Then choose option 2 to add to path
Then quit the setup menu
sudo reboot

3. Now you should be able to build Circle as per the build instructions in the Circle README.md
Don't forget to run make in the "boot" folder to download the boot binaries.

Then I built sample 03-screentest to test it, and copied the kernel.img (and the boot binaries from the boot folder) to my 512MB SD card (FAT formatted by a digital camera). To do this I used a Windows laptop to copy the files (using WinSCP) from the Raspbian RPi to the 512MB SD card in the laptop's card reader.

Then I shut down the RPi, pull out the Raspbian SD card, and put in the 512MB SD card with the Circle stuff on it.

It would not work properly until I created the cmdline.txt file on the SD card, with option "width=640 height=480" (as described in the 03-screentext/README).

Awesome to see something boot in 3 seconds :)

Now I need to figure out how to build my Circle apps on one RPi, and then copy the kernel.img to another "target" RPi (maybe via serial?). Is there some kind of "boot menu" binary that loads and runs another binary over serial or network?

PS: Nice to see that it supports the 1-wire protocol, I already have a project using 1-wire via Python, maybe it could be converted to Circle.

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 6:55 am

jum wrote:First of all, thanks for this great work :)
Thank you!
I want to share how I managed to build Circle on the Raspberry Pi (in case other people are also trying to do this). The reason you might want to do this is because you want to write and build Circle apps on your RPi, rather than installing a cross-compiler on Linux or Windows laptop/PC.
Thanks for finding out how to build Circle on the RPi itself using the ARMinARM installation scripts and supplying this info!

Let me note that the toolchain supplied with Raspbian was useable too (at least in the past) if the PREFIX= variable is made empty in Rules.mk. But I haven't tried this for a while.
It would not work properly until I created the cmdline.txt file on the SD card, with option "width=640 height=480" (as described in the 03-screentext/README).
There may be a problem in Circle (BTW also in the USPi environment) which tries to detect the optimal screen size and seems to fail with it using some displays. I will add a fix to Circle (also to USPi) which will force Circle to a screen size of 640x480 pixels in this case.
Now I need to figure out how to build my Circle apps on one RPi, and then copy the kernel.img to another "target" RPi (maybe via serial?). Is there some kind of "boot menu" binary that loads and runs another binary over serial or network?
I used u-boot for a while on the RPi 1 which is able to load the kernel image from a TFTP server over network.
PS: Nice to see that it supports the 1-wire protocol, I already have a project using 1-wire via Python, maybe it could be converted to Circle.
Have fun!

jspeccy
Posts: 16
Joined: Sun Nov 30, 2014 6:25 pm

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 8:08 am

I'm playing with Circle and I have an USB<->Serial converter for the PI. On uSD I have a slightly modified bootloader from official raspberry repo in github. So, I can send the new kernel.img at 1Mbps.

I use the official toolchain, because I've found some problems with arm-none-eabi from launchpad.net (and code generated is slower, I don't know why).

I've done a fork from the rst repo and added a few modifications, as support for virtual resolutions and colour palettes with a depth less than 8-bits, and a fast function for change byte ordering (unneeded anyway, because we have a gcc builtin for this).

Now, I'm trying to find an USB bug in sample #18, that hangs the PI when an USB keyboard and mouse are attached to PI. But I need to understand first the SPLIT transactions on USB bus....

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 10:08 am

jspeccy wrote:I've done a fork from the rst repo and added a few modifications, as support for virtual resolutions and colour palettes with a depth less than 8-bits, and a fast function for change byte ordering (unneeded anyway, because we have a gcc builtin for this).
Thanks for enhancing Circle! But sorry because of some reasons explained in a comment to your pull request on GitHub I will not include these changes into my repository. Perhaps you should provide a link to your repo so that people can use it who are interested in.
Now, I'm trying to find an USB bug in sample #18, that hangs the PI when an USB keyboard and mouse are attached to PI. But I need to understand first the SPLIT transactions on USB bus....
I will try to reproduce this problem.

jspeccy
Posts: 16
Joined: Sun Nov 30, 2014 6:25 pm

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 10:26 am

rst wrote:
jspeccy wrote:Now, I'm trying to find an USB bug in sample #18, that hangs the PI when an USB keyboard and mouse are attached to PI. But I need to understand first the SPLIT transactions on USB bus....
I will try to reproduce this problem.
A few tips. When the sample code starts, you can ping the pi. Between five to twenty seconds after the start, all freezes, no keyboard response, no mouse response and not net response. Sometimes, freezes immediately, sometimes freezes after one minute. I guess it's not relevant that only the keyboard or mouse are connected.

But I've found that increment the timer interrupt from 100 to 200 or 250 ints/sec, mitigates the problem. I suspect that a stalled split transaction with keyb or mouse causes a more general problem to USB layer. But it's a really difficult bug to trace... again!. :D

Thanks by your time. ;)

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 12:18 pm

jspeccy wrote:A few tips. When the sample code starts, you can ping the pi. Between five to twenty seconds after the start, all freezes, no keyboard response, no mouse response and not net response. Sometimes, freezes immediately, sometimes freezes after one minute. I guess it's not relevant that only the keyboard or mouse are connected.
Thanks for this info! I can reproduce the problem on a RPi 1 Model B+ but only with both keyboard and mouse connected.
But I've found that increment the timer interrupt from 100 to 200 or 250 ints/sec, mitigates the problem. I suspect that a stalled split transaction with keyb or mouse causes a more general problem to USB layer.
A STALL in any transaction should end up with a "Transaction failed" log error message.

There was a similar problem when porting Circle to the RPi 2 with multi-core support. Please read the last paragraph in doc/multicore.txt. A workaround can also be a short delay (e.g. 2 ms) at the end of the main loop in CKernel::Run(). This will slightly raise the ping response time but normally your application can do other things instead of the delay.

I think this problem is difficult to overcome in another way. The reason is the simple design of the frame scheduling which only tries to start a (split) transaction in the right USB microframe. The more USB devices are used at the same time and produce traffic (as keyboard and mouse do all the time because they are polled by an interrupt transfer) the less well this frame scheduling will work. If the Ethernet device is polled as fast as possible (without delay) too it does not seem to work anymore.

Perhaps you can manage this using such a short delay? ;)

jspeccy
Posts: 16
Joined: Sun Nov 30, 2014 6:25 pm

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 2:44 pm

rst wrote: There was a similar problem when porting Circle to the RPi 2 with multi-core support. Please read the last paragraph in doc/multicore.txt. A workaround can also be a short delay (e.g. 2 ms) at the end of the main loop in CKernel::Run(). This will slightly raise the ping response time but normally your application can do other things instead of the delay.

I think this problem is difficult to overcome in another way. The reason is the simple design of the frame scheduling which only tries to start a (split) transaction in the right USB microframe. The more USB devices are used at the same time and produce traffic (as keyboard and mouse do all the time because they are polled by an interrupt transfer) the less well this frame scheduling will work. If the Ethernet device is polled as fast as possible (without delay) too it does not seem to work anymore.

Perhaps you can manage this using such a short delay? ;)
I've reproduced the problem using delays of 10 ms. It's a question of time, simple statistics. Sometimes after 100 pings, sometimes after 500, but the problem is here. Now, I'm only testing Circle, and works OK. I see what to do with this problem when I need.

Thanks

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 6:52 pm

jspeccy wrote:I've reproduced the problem using delays of 10 ms. It's a question of time, simple statistics. Sometimes after 100 pings, sometimes after 500, but the problem is here. Now, I'm only testing Circle, and works OK. I see what to do with this problem when I need.
I have added an issue on GitHub. As you said that's a difficult one.

jum
Posts: 19
Joined: Wed Mar 20, 2013 12:18 pm

Re: Circle - C++ bare metal environment (with USB)

Thu Sep 24, 2015 7:17 pm

Thanks rst for the feedback and the tip about uboot. I will try the empty PREFIX= thing and let you know.

PS: jspeccy thanks for the info about the modified bootloader. I have been using uboot to upload a test executable via FTDI serial (using uboot "loady" command, then "go" command), but the test exe just shows a blank screen (after 5 blinks on the LED). I will try your bootloader next.

Update: jspeccy's bootloader05 (see link above) worked 1st time for me. I also notice that the test executable I loaded using the bootloader still used the cmdline.txt settings (which is nice).

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Sun Sep 27, 2015 1:24 pm

rst wrote:
jspeccy wrote:I've reproduced the problem using delays of 10 ms. It's a question of time, simple statistics. Sometimes after 100 pings, sometimes after 500, but the problem is here. Now, I'm only testing Circle, and works OK. I see what to do with this problem when I need.
I have added an issue on GitHub. As you said that's a difficult one.
I have found a (probably the) problem and I guess I could fix it. The ping test now runs one hour without freezing (and without delay).

Please read Circle issue #10 and the most recent commit notes on GitHub if you are interested in!

Thanks.

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Fri Nov 06, 2015 12:54 pm

I want to inform that single-core Circle applications can be source-level debugged using the GNU debugger and rpi_stub by turboscrew on the Raspberry Pi 2 now. Please see the file doc/debug.txt in the Circle tree and the rpi_stub documentation for further info. Thanks to turboscrew for providing rpi_stub!

Barri
Posts: 6
Joined: Sun Dec 06, 2015 12:26 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Sun Dec 06, 2015 12:30 pm

Which kind of display can i use with the Circle C++ project ?

- normal hdmi display - ok
- a lcd display with spi control ?

like this

http://www.sainsmart.com/sainsmart-3-5- ... 2-b-b.html

rst
Posts: 277
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: Circle - C++ bare metal environment (with USB)

Sun Dec 06, 2015 5:29 pm

SPI support is currently not available in Circle yet. Although it could be added an additional display driver would be needed too. Normal HDMI displays should work of course.

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 8 guests