355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

dexbasic questions

Sat Feb 15, 2014 9:13 pm

I just saw some postings on the forum about dexos and dexbasic and am very interested in trying this out. At this site:
http://www.dex-os.com/DexBasic/DexBasic.htm
I found instructions and followed them but my R-Pi lays there and just smirks at me.

One difference I noted is that the Intro tutorial shows FAT32 formatting (Idid) and it shows Allocation Unit Size of 16KB while my system offered no choice here and ended up with 32KB size. Could this be a problem?

And just to be clear, here is what my card directory looks like:
  • Volume in drive G has no label.
    Volume Serial Number is 9024-693E

    Directory of G:\

    10/28/2012 05:40 PM 2,347,828 start.elf
    10/28/2012 05:40 PM 17,764 bootcode.bin
    08/03/2012 03:03 PM 33 config.txt
    06/25/2012 12:33 PM 1,476 LICENCE.broadcom.txt
    02/15/2014 12:42 PM 43,792 kernel.img
    5 File(s) 2,410,893 bytes
    0 Dir(s) 2,024,816,640 bytes free
When I power up the Pi, the monitor sees a signal on the HDMI cable and powers on but no text is displayed.

Hints anyone? Thanks!

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: dexbasic questions

Sun Feb 16, 2014 12:03 am

355/113 wrote:I just saw some postings on the forum about dexos and dexbasic and am very interested in trying this out. At this site:
http://www.dex-os.com/DexBasic/DexBasic.htm
I found instructions and followed them but my R-Pi lays there and just smirks at me.

One difference I noted is that the Intro tutorial shows FAT32 formatting (Idid) and it shows Allocation Unit Size of 16KB while my system offered no choice here and ended up with 32KB size. Could this be a problem?

And just to be clear, here is what my card directory looks like:
  • Volume in drive G has no label.
    Volume Serial Number is 9024-693E

    Directory of G:\

    10/28/2012 05:40 PM 2,347,828 start.elf
    10/28/2012 05:40 PM 17,764 bootcode.bin
    08/03/2012 03:03 PM 33 config.txt
    06/25/2012 12:33 PM 1,476 LICENCE.broadcom.txt
    02/15/2014 12:42 PM 43,792 kernel.img
    5 File(s) 2,410,893 bytes
    0 Dir(s) 2,024,816,640 bytes free
When I power up the Pi, the monitor sees a signal on the HDMI cable and powers on but no text is displayed.

Hints anyone? Thanks!
Hi 355/113
Here's some things you can try, first try this up dated ver of DexBasic
http://www.dex-os.com/DexBasic/Tut1.zip
if that does not work, try replacing the boot files eg:
start.elf
bootcode.bin
With file of the same name from here:
https://github.com/raspberrypi/firmware ... aster/boot

Also if that does not work you can try install a linux distro to your SD card and replacing kernel.img with the one in the zip.
Let me know how you get on, and we can go on from there.

PS: You can tell if the OS is loaded, by the OK led should stay on.
Batteries not included, Some assembly required.

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Sun Feb 16, 2014 4:22 am

Thanks!!

I'll try that and report back how it worked. I'm excited to get this going if I can - just read the earlier posts about fast bit toggles and would like to do some of that with dexbasic if possible.

Thanks again!

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Sun Feb 16, 2014 4:32 pm

Success!

First, I must apologize for the wild goose chase - this morning I deleted all the files and started over with the tutorial. I noticed that the 'OK' led in fact did flash and the monitor was getting video. Bad video but it was present. The screen was mostly black with 10 or 15 lines of flashing pixels scrolling up the screen repeatedly. Looked like the scan rates were way off or sync was missing. It was too dark to see yesterday but this morning was apparent.

So next, I ran your newer tutorial1 and now the bmp is on the screen along with lines of text. For reference, I'll save a disk image to fall back to if mucking around with it messes things up.

Thank you for your help!!!!

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: dexbasic questions

Sun Feb 16, 2014 11:00 pm

Glad you got it working, it seem the DexBasic.zip on the site is a very old ver, i up loaded a old ver by mistake, i will up date it with the new ver.
But if you follow the tuts, use the files from Tut1.zip and just replace the app.asm with the tut your following.
I will be adding a lot more functions and demo's soon.
Batteries not included, Some assembly required.

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Tue Feb 18, 2014 1:27 am

Now I have the bitbang tutorial code running and out of curiosity, I removed the delays between the bit set and the bit clear commands to see how fast it could toggle a pin as well as how long the goto would take.

I'm seeing about 900ns for the bit set period and around 1.1us for the combination of the bit clear and the goto. Knowing absolutely nothing about the Broadcom Arm chip architecture, does this sound reasonable? I seem to recall seeing a forum topic that suggested 12.5ns might be the fastest pin toggle rate.

Is there anything I might do to speed things up?

Thanks!!!
BTW - having great fun with this! Thank you!

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: dexbasic questions

Tue Feb 18, 2014 2:48 am

355/113 wrote:Now I have the bitbang tutorial code running and out of curiosity, I removed the delays between the bit set and the bit clear commands to see how fast it could toggle a pin as well as how long the goto would take.

I'm seeing about 900ns for the bit set period and around 1.1us for the combination of the bit clear and the goto. Knowing absolutely nothing about the Broadcom Arm chip architecture, does this sound reasonable? I seem to recall seeing a forum topic that suggested 12.5ns might be the fastest pin toggle rate.

Is there anything I might do to speed things up?

Thanks!!!
BTW - having great fun with this! Thank you!
Hi 355/113, Glad you having fun, the code is not optimized at all, i know very little about electrics side and have no test equipment, but i am sure we can get much faster pin toggle with your help.
Too start with can you add the bellow code to see if that speed it up a bit.

Code: Select all

; Start L1 Cache
mov r0,0
mcr p15,0,r0,c7,c7,0 ; Invalidate Caches
mcr p15,0,r0,c8,c7,0 ; Invalidate TLB
mrc p15,0,r0,c1,c0,0 ; Read Control Register Configuration Data (ARM1176JZF-S r0p7 3-44)
orr r0,$1000 ; Instruction
orr r0,$0004 ; Data
orr r0,$0800 ; Branch Prediction
mcr p15,0,r0,c1,c0,0 ; Write Control Register Configuration Data
Add to the code like this

Code: Select all

include 'DexBasic\DexBasic.inc' 		   ; set up everything and stores our macros etc
						   ;
; Start L1 Cache
mov r0,0
mcr p15,0,r0,c7,c7,0 ; Invalidate Caches
mcr p15,0,r0,c8,c7,0 ; Invalidate TLB
mrc p15,0,r0,c1,c0,0 ; Read Control Register Configuration Data (ARM1176JZF-S r0p7 3-44)
orr r0,$1000 ; Instruction
orr r0,$0004 ; Data
orr r0,$0800 ; Branch Prediction
mcr p15,0,r0,c1,c0,0 ; Write Control Register Configuration Data

pinMode  GPIO16, OUTPUT 			   
align 4						 
LetsLoop:					   
digitalWrite  GPIO16, HIGH			 
digitalWrite  GPIO16, LOW			 
goto  LetsLoop					  
					
align 4 					  
ProgramSize:					 
ScreenBuffer:					 
Thanks.
Batteries not included, Some assembly required.

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Tue Feb 18, 2014 4:36 am

That runs a bit faster - it was around 500kHz, now it looks like this:
Pin high time = 790ns
Pin low time = 805ns
Approx freq = 629kHz

Again, thank you for helping me.

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

Re: dexbasic questions

Tue Feb 18, 2014 8:38 am

If you want it faster, you're going to need to lose Dex's DigitalWrite macro and toggle the bit yourself. As it stands, each digitalwrite incurs (in your loop) 3 stack pushes, 3 stack pops, 3 (hideously inefficient) immediate loads and a function call (don't have ARM tools installed on this machine, can't see what the function itself does). For the purposes of toggling a pin, you should have one "large" immediate load (outside the loop, and can be done way better than Dex's imm32, although, to be fair, I can't see how Dex could do it differently using fasmarm macros) and one "small" immediate load (one bit, easily fits within an ARM "modified 12 bit constant", i.e. a single mov). Within your loop, you need one indirect load, one exclusive or, one indirect store, and a synchronisation barrier.

This is typed directly into the browser, does not contain correct addresses or bit numbers, and may well be wrong. But it gives an idea of what your code should look like

Code: Select all

    ; Load address of GPIO register, use Dex's imm32 macro even if it's inefficient
    imm32 r0, 0x12345678
    ; load bit to toggle
    mov r1, 1 << 15
; loop starts here
loop:
    ; data synchronisation barrier
    mcr p15, 0, r3, c7, c10, 4
    ; load contents of register
    ldr r2, [r0]
    ; toggle bit
    eor r2, r2, r1
    ; write register back
    str r2, [r0]
    ; and go round again
    b loop

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Tue Feb 18, 2014 7:00 pm

Very interesting! I'll look into that when I get home this evening.
Thanks!

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

Re: dexbasic questions

Tue Feb 18, 2014 8:04 pm

You could, of course (and as long as you don't care about the state of any of the other GPIOs on that register) pull the ldr out of the loop as well - i.e. read the value at start, then toggle / write / barrier repeatedly. That might gain you some cycles.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: dexbasic questions

Wed Feb 19, 2014 1:09 am

tufty right, you need to keep the macros out of the main loop.
I have added a test macro, to see if that helps ,see zip
http://www.dex-os.com/DexBasic/Fast.zip

The basic code is

Code: Select all

include 'DexBasic\DexBasic.inc'                    ; set up everything and stores our macros etc
                                                   ; NOTE: CHANGE BOTH THESE, TO THE PIN YOU WANT (UP TO PIN 31)
pinMode  GPIO16, OUTPUT                            ; set GPIO 16 as output
gpioAddress 16                                     ;
align 4                                            ;
LetsLoop:                                          ; a label
str r0, [r1,0x1C]                                  ;
str r0, [r1,0x28]                                  ;
b  LetsLoop                                        ; jump back to label LetsLoop, and repeat the code
                                                   ;
align 4                                            ; make sure the next bit aligned on a 4 byte boundary
ProgramSize:                                       ; this label is so we can work out, the size of this program
ScreenBuffer:                                      ; this label is where our off screen buffer is
Change the gpio numbers to suit.
Let me know if its much faster, thanks.
Batteries not included, Some assembly required.

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Wed Feb 19, 2014 2:53 am

This line:

Code: Select all

gpioAddress 16                                     ;
caused the fasmwarm program to declare "Error: illegal instruction"

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: dexbasic questions

Wed Feb 19, 2014 3:25 am

355/113 wrote:This line:

Code: Select all

gpioAddress 16                                     ;
caused the fasmwarm program to declare "Error: illegal instruction"
Make sure you use the 'DexBasic\DexBasic.inc from the fast.zip
Attachments
Screenshot.png
Screenshot.png (50.36 KiB) Viewed 4120 times
Batteries not included, Some assembly required.

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Wed Feb 19, 2014 3:51 pm

Now it compiles - thank you! I'll run it this evening.

355/113
Posts: 26
Joined: Wed Aug 22, 2012 2:22 am

Re: dexbasic questions

Thu Feb 20, 2014 1:58 am

Now operation is:
High = 80ns
Low = 33ns
Period = 113ns
Freq = about 8.9MHz
So that's quite an improvement. Knowing nothing about bare-metal mode on the Pi, I'm learning a lot. I just found the "Baking Pi" tutorial at: http://www.cl.cam.ac.uk/projects/raspbe ... orials/os/
and will try out some of that stuff too.

I wrote an arm assembly program about 10 years ago simply by loading a PIC16F assembly file into an arm assembler and slowly eliminating the syntax errors. It was very interesting but I did not take it any farther.

Right now I need to change horses and get some serial port stuff working on my Pi for some lab data collection experiments.
Thanks for all your help!

colinh
Posts: 95
Joined: Tue Dec 03, 2013 11:59 pm
Location: Munich

Re: dexbasic questions

Sat Feb 22, 2014 6:19 pm

355/113 wrote:I wrote an arm assembly program about 10 years ago simply by loading a PIC16F assembly file into an arm assembler and slowly eliminating the syntax errors.
:lol: Brilliant!

I tend to recommend this book a lot: ARM Assembly Language Programming by Peter Cockerell. It's long out of print, being about the original ARM v2, but it's a good introduction.

tvjon
Posts: 802
Joined: Mon Jan 07, 2013 9:11 am

Re: dexbasic questions

Wed Feb 26, 2014 12:18 pm

Also useful is:

https://www.amazon.co.uk/Archimedes-Ass ... 1870336208

particularly if you're interested in looking at RISCOS.

schluss
Posts: 4
Joined: Fri Mar 21, 2014 9:41 am

Re: dexbasic questions

Fri Mar 21, 2014 9:51 am

Hi,

As the dex-os.com site is suspended, where can I find the dex-basic.zip file and the other infos?

KR
schluss

Return to “Bare metal, Assembly language”