EASy68K  
It is currently Sat Dec 07, 2019 9:58 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Apr 09, 2019 5:54 pm 
Offline

Joined: Tue Mar 06, 2018 6:39 am
Posts: 4
Last year I built a simple 68k single board computer with a serial interface and wrote a simple monitor program for it using assembly in Easy68k. It has 512k each of RAM and ROM.

I'd like to be able to compile C for it, so I've been doing some reading online and I was able to build GCC as a cross-compiler for m68k-elf.

So, theoretically I can now compile C for the 68k, but I'll probably need to use some of my assembly routines for things like serial I/O and initializing the UART, right? stdio.h is going to be useless here. What's the best way to go about this?

I thought I could take some of the assembly I wrote in Easy68k and use the GNU assembler to produce object code that I'd be able to link alongside C-generated object files, but the GNU assembler has some major issues with my code. Any of the EQU lines at the start it takes issue with. Any instruction that has a label is considered invalid. And most of my inline comments cause problems, too.

Is it probably just a syntax issue, or would it be better for me approach this differently? I looks like maybe it's also possible to issue assembly instructions directly from inside a C program; is that a better idea? I've also read a little online about "newlib" which seems like it might be helpful, but I just thought I'd ask here to see if anyone could point me in the right direction.

Thanks for any insight you are able to share.


Top
 Profile  
 
PostPosted: Mon Nov 25, 2019 7:31 pm 
Offline

Joined: Fri Oct 25, 2019 8:15 pm
Posts: 7
You and I are in the same boat, Wondering if you ever got an answer?

From what I saw online, you use newlibc and modify the board support package. And unfortunately, thats where "help" ends as I dont know how to "patch in" driver code into newlibc.


Top
 Profile  
 
PostPosted: Tue Nov 26, 2019 12:22 am 
Offline

Joined: Thu Mar 08, 2018 6:00 pm
Posts: 2
Hey all! I've been working on something similar, a breadboarded 68K, and may be able to offer some help!

I also have built myself the GCC 68K cross compiler and have a complete toolchain working with CodeBlocks.

Here is a link to the git repo of the project: https://gitlab.thenybble.com/nybble/m68k-baremetal

To walk through some of the project:

bin - Contains the Debug and Release executable files. The file extension is .EXE but I assure you, it's not a Windows executable. In fact, it's not an ELF executable either. That's just the default extension CodeBlocks throws on binary files on Windows.

include - Header files for the project. ASM.H is used by crt0.S in the src folder to define some of the hardware information. Display.h is for a simple 16x2 character display tied directly to the address bus. Exceptions.h is me wading into using GCC to define interrupts and exception handlers.

link - My custom linker script for the linker. This tells the linker to output in raw binary format instead of ELF. The SYS area is defined as the first 1K of memory (RAM or ROM) and holds the reset vectors and vector table for exception processing. You can customize these as you need them. Redefine them as RAM and ROM, or even break them down into things like SYS_ROM, USER_ROM, RAM, etc.

obj - Intermediate object code. Don't worry about it!

src - The good stuff. crt0.S Setup the environment, setup the stack frame, clear BSS, call main, call _exit and halt the processor, define the reset vectors and the exception table, etc.
sbrk.c - Hey, did I mention this thing supports dynamically allocating RAM? A simple sbrk routine for malloc! Exceptions.c - How to use the __attribute__ tag to tell GCC to setup the function for interrupt handling, like moving use RTE (Return from Exception) instead of RTS (Return from Subroutine) for these interrupt handlers.

Just make sure that your cross compiler has NewLib available, and it should all compile in CodeBlocks!]

I'll be around to answer questions if you have any! Wade through the code - It should be easy to adapt to support a UART module using a volatile pointer if you're doing memory mapped I/O, which I'm pretty sure all the 68K supports ;)


Top
 Profile  
 
PostPosted: Tue Nov 26, 2019 9:36 pm 
Offline

Joined: Mon Apr 11, 2005 12:57 am
Posts: 28
Location: Australia
@nybble, I'd really be interested in the steps you used to complie your own 68k toolchain for CodeBlocks. I've had a few attempts myself and I've never got far due to the lack of clear information.


Top
 Profile  
 
PostPosted: Tue Nov 26, 2019 10:05 pm 
Offline

Joined: Thu Mar 08, 2018 6:00 pm
Posts: 2
If you're working on Windows, you can build the cross-compiler and NewLib for MinGW - That's detailed here: http://www.aaldert.com/outrun/gcc-auto.html

They provide an nice automated script that'll do it all for you. If you're on Linux, you can follow their manual MinGW steps here: http://www.aaldert.com/outrun/gcc.html

Doing it manually, either in Windows or in Linux allows you to download the latest version of BinUtils, GCC, and NewLib, and not depend on the hardcoded versions in the script. I've got the cross-compiler working using the latest BinUtils, GCC, and NewLib.

Once you get the cross-compiler setup, open Code::Blocks, and go into Compiler Settings

Select *No Compiler*, click "Copy", and give it a meaningful name. Mine for instance is "GNU GCC Compiler for M68K"

Under "Toolchain executables" you may be able to autodetect your GCC M68K install, if not, just drop in the bin path for the cross-compiler and specify m68k-elf-gcc (.exe if you're on Windows) for all options except the linker.

This is really a high level overview, but should be enough to get you started. Let me know if you run into any bumps and I'll help how I can!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group