ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

which simple, close to metal OS, has fast write to SDcard ?

Thu Mar 05, 2015 3:19 am

which simple, close to metal OS, has fast write to SDcard ?


Why ?
i want to feed data , lots of data (i.e. 200-500Mbytes ), quickly, to a rpi2 & have it write the data out to SD in a file system (IE fat32) - several times , into several files (32or 64 gig card...)
i can then pluck out the card & dump the data to a pc for further processing/analysis...

don't need frame buffer (except to debug ...) or Ethernet or USB (though saving to a USB drive would be a nice option) .. writing can take its time ..

any ideas or suggestions ??

ghans
Posts: 7867
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: which simple, close to metal OS, has fast write to SDcar

Thu Mar 05, 2015 8:40 am

Please give an actual value of the minimum write speed your project needs , because actually the Linux driver should be the best one already.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23059
Joined: Sat Jul 30, 2011 7:41 pm

Re: which simple, close to metal OS, has fast write to SDcar

Thu Mar 05, 2015 8:55 am

I suspect the limitation may be the card itself, rather than the SD card interface.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
rpdom
Posts: 14686
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: which simple, close to metal OS, has fast write to SDcar

Thu Mar 05, 2015 9:03 am

If not using ethernet or USB, how are you planning to get the data to the Pi?

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Thu Mar 05, 2015 2:40 pm

longer version of whats happening on input

I will use a fpga to feed 12-16bit data at 2-10MBytes/sec to the rpi gpios
(code is 70%-90% written)

previous project with a Arduino Due was able to get up to 500kbytes per sec
i need to get those extra couple orders of magnitude

BUT
since the rpi's have no external bus this can't be DMA'd
& has to be ack/nak read from the fpga -
the data will look like 16 bits but will need to be shifted & masked before each save (from a 32 bit gpio register read )

maybe 15 ASM instructions in the loop
(this is a wild guess but based on previous ASM experience)

i would want either uart or i2c for fpga configuration communications so i have to be careful of which gpios are used

this can't be irq driven nor this is possible in a multi tasking environment
just a tight loop saving to contiguous ram till a "end condition " is reached

this will happen continuously for up to 5min
- then it STOPS & data is saved to SDcard (Or USB ..??.)
- i don't really care how long saving takes -faster is better but data integrity is more important than speed

single threaded processes - (& yes it may be possible to deal with multiple processors & etc to save at the same time but that is a different discussion)


so single threaded basic file operations ? micro kernel ?

ghans
Posts: 7867
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 8:02 am

5 * 60 s * 80 Mbit/s = 24 gigabit , so this won't fit in the RAM of any Pi model. I think the Pi can write class 10 SD cards at max speed linearly
(contrary to random access R/W) , but i'm not sure.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 11:45 am

ok - i can't do 5 min ...

but should be able to do 1 - 2 min (and 10Mbytes/sec is a theoretical max )
so 60secx10Mbytes/sec -> 600Meg so 1.5 theoretical -> 900Meg ...
& chances are I'll be hitting 3Meg/sec rather than 10 anyway .....

it is vague because there are other factors & i'll take the fastest & longest period i can in any case

do most of these have write capabilities or is it that no one has checked which is "best" ?

ghans
Posts: 7867
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 12:29 pm

Class 10 (specified for minimum 10 Megabyte/s write speed) SD cards are optimized for your use case : long , continous writes.
Most Pi users find them not that useful since Linux needs good random access performance instead.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ghans
Posts: 7867
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 1:14 pm

Looking at it again , i see no reson why you can't achieve 80Mbit/s write speed with a program running under Raspbian.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 1:17 pm

yes / but i'm not asking about SDcards

i'm inquiring about software to write to them in a structured manner (IE fat32)

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 1:24 pm

can you run a tight loop under Rasbpian that will input for 2 min without any interruptions ?

writing to sd is the tail end, important & interruptible
my biggest concern is writing the data with virtually 0 latency to ram off gpio
multitasking OS's tend to get cranky if you don't let them swap processes for a couple min.

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

Re: which simple, close to metal OS, has fast write to SDcar

Fri Mar 06, 2015 3:24 pm

ralphnev wrote:I will use a fpga to feed 12-16bit data at 2-10MBytes/sec to the rpi gpios
(code is 70%-90% written)

previous project with a Arduino Due was able to get up to 500kbytes per sec
i need to get those extra couple orders of magnitude

BUT
since the rpi's have no external bus this can't be DMA'd
& has to be ack/nak read from the fpga -
the data will look like 16 bits but will need to be shifted & masked before each save (from a 32 bit gpio register read )
You probably won't get more than about 3 MHz sample rate when reading GPLEV0 on the Raspberry Pi 2. With 16 valid bits at a time that would be 6 MByte/s at most (probably a little bit less). The problem here is the time needed to read the register (defined as shared device in the page table, non-shared makes no difference). The Pi 1 is 4-5 times faster here.

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 12:10 am

rst wrote:You probably won't get more than about 3 MHz sample rate when reading GPLEV0 on the Raspberry Pi 2. With 16 valid bits at a time that would be 6 MByte/s at most (probably a little bit less). The problem here is the time needed to read the register (defined as shared device in the page table, non-shared makes no difference). The Pi 1 is 4-5 times faster here.
What ??
I expected a delay but why so slow ??
i had originally purchased a rpi(A) for this purpose 2 years ago expecting a better gpio
but it did not have enough width
now there is width but it is slowed down ????

aaaghhh ...

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 8:17 am

I'm no expert on the Pi's GPIO, but I strongly suspect that the Pi isn't the tool you need here. Linux will almost certainly be getting in the way, which means bare metal (or nearly so) access, and even then I think you're probably going to be fighting the architecture.

For what you're wanting, you probably want a microcontroller. One of the ARM-based ones like the STM32xx, LPC43xx or SAM9 would probably be a decent fit, and have enough grunt to handle both GPIO and SD write. SAM9R have DMA enabled SDIO, IIRC. Once you have a list of potential controllers, start looking for cheap evaluation boards.

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

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 10:20 am

ralphnev wrote:What ??
I expected a delay but why so slow ??
i had originally purchased a rpi(A) for this purpose 2 years ago expecting a better gpio
but it did not have enough width
now there is width but it is slowed down ????
I was also astonished when I did this measurement on the Pi 2. I do not know the reason for this and I hope I did not miss something in interpreting the result. If you want to check it by yourself you can do it with this sample program . It can be build for Pi 1 (default) and Pi 2. Please see the main project README for building instructions.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5282
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 1:20 pm

rst wrote:I was also astonished when I did this measurement on the Pi 2. I do not know the reason for this and I hope I did not miss something in interpreting the result. If you want to check it by yourself you can do it with this sample program . It can be build for Pi 1 (default) and Pi 2. Please see the main project README for building instructions.
There is no hardware reason for Pi2 to be slower than Pi when reading gpio.
Can you try adding to config.txt:

Code: Select all

arm_control=0x1000
and running your Pi2 test again?

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 1:55 pm

tufty wrote:I'm no expert on the Pi's GPIO, but I strongly suspect that the Pi isn't the tool you need here. Linux will almost certainly be getting in the way, which means bare metal (or nearly so) access, and even then I think you're probably going to be fighting the architecture.

For what you're wanting, you probably want a microcontroller. One of the ARM-based ones like the STM32xx, LPC43xx or SAM9 would probably be a decent fit, and have enough grunt to handle both GPIO and SD write. SAM9R have DMA enabled SDIO, IIRC. Once you have a list of potential controllers, start looking for cheap evaluation boards.
most of the small micros don't have the memory --
more details - this isn't a new project - i have used a Arduino Due (Sam3x8- 96kbytes ram) - and got up to .5-1Meg/sec using the internal ADC & DMA -- BUT always hamstrung by the lack of ram & the relatively slow sdcard write -- and new projects get bigger faster
so in the last 2 months i have built a peripheral that handles the sensor timing / external ADC / & provides some latency protection through a big fifo - but what i need is to dump the data to alot of ram & write it out ...

I am building slit scan cameras -
here is the current ver. (#3) http://ralph.ca/other/slitscan_writeup/
and images http://slitscan.us/spring-2014/nggallery/slideshow (slow site ...)
for version #4 i would like to increase the speed *2 & resolution *2.5 - still b/w
& #5 colour (3x data & 1.5 increase in resolution...)

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

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 4:58 pm

dom wrote:There is no hardware reason for Pi2 to be slower than Pi when reading gpio.
Can you try adding to config.txt:

Code: Select all

arm_control=0x1000
and running your Pi2 test again?
Yes! That works. I get a GPIO sample rate of over 9 MHz with it and over 11 MHz with additional "arm_freq=900 & force_turbo=1" in the config.txt. That's near to the results of the Pi 1. Thank you. It would be interesting to know what this statement does to the Pi 2?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23059
Joined: Sat Jul 30, 2011 7:41 pm

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 5:51 pm

rst wrote:
dom wrote:There is no hardware reason for Pi2 to be slower than Pi when reading gpio.
Can you try adding to config.txt:

Code: Select all

arm_control=0x1000
and running your Pi2 test again?
Yes! That works. I get a GPIO sample rate of over 9 MHz with it and over 11 MHz with additional "arm_freq=900 & force_turbo=1" in the config.txt. That's near to the results of the Pi 1. Thank you. It would be interesting to know what this statement does to the Pi 2?
Yes, it would!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5282
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 6:21 pm

Pi2 has 4 cores. They all start executing on reset.
By default the boot code makes 3 of the cores (busy) wait for a signal from the first core.
Linux will trigger this once some init code has been run (i.e. within the first millisecond).

Your bare metal environment doesn't wake the other cores up, which means they keep polling a register, and so compete on the bus with the useful work you want the first core to do.

Code: Select all

arm_control=0x1000
changes the "cmp r0, #0xff" to be a cmp r0, #0x1", which causes the secondary cores to not poll for the signal, but just to sleep.

This was obviously just a debug switch when trying to get mulitcore linux working, which fortunately hasn't been removed yet.

The real solution is for your bare metal world to wake up the other cores and make them sleep, or change the bootcode to sleep directly.

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

Re: which simple, close to metal OS, has fast write to SDcar

Sat Mar 07, 2015 6:41 pm

OK. Understood. I will see how I can handle this in my bare metal code. Thanks for explaining this!

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Sun Mar 08, 2015 7:27 pm

ummmm ...
studying the limited documentation

has anyone successfully attached a 16 bit device onto the "Secondary Mem Address Bus" ?
or does anyone know what address block it starts at ??

this looks like i may solve my interface problems ...

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11993
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: which simple, close to metal OS, has fast write to SDcar

Sun Mar 08, 2015 9:38 pm

Perhaps not exactly the same thing, but Gert van Loo's VGA666 adapter also uses the 16-bit bus, although he uses another alt function. But perhaps reading its documentation will give you some pointers.

Also, I think the BMC2835 ARM peripherals document has a section about it: http://www.raspberrypi.org/documentatio ... herals.pdf

I think all I/O registers were moved because of the upgrade to 1GB on a PI2B, i think to the top of the 1GB memory segment.
sorry I can't be clearer, I'm not that much into bare metal.

ralphnev
Posts: 14
Joined: Thu Mar 05, 2015 2:47 am
Location: Ottawa,Ontario Canada

Re: which simple, close to metal OS, has fast write to SDcar

Sun Mar 08, 2015 10:05 pm

yes i was examining the vga666 -- but couldn't find any code associated with it (only the bin)
I've pored over the peripheral manual but only mention of secondary memory bus is in the gpios

just wrote a quickie to go running amok though memory & monitor via Logic analyzer
though haven't tried it yet ...

if i can have the secondary addresses bus -
i won't need to be in bare metal / would just have to write a kernel driver for a periodic DMA ... (differnt problems ;)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11993
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: which simple, close to metal OS, has fast write to SDcar

Sun Mar 08, 2015 10:21 pm

looked a bit around, and found this:
Peripherals base address for older models was 0x20000000, base address for Pi 2 is 0x3F000000.
hope it helps.

Return to “Bare metal, Assembly language”