Debugging my first SBC

Building your first 6502-based project? We'll help you get started here.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Help using cc65

Post by BigEd »

sepseel wrote:
Ok, so I managed to get the bash prompt in windows 10 to work.
Now you say i should install cc65 using the apt-get install command, however when I input: sudo apt-get install cc65,
I get an error saying: unable to locate package cc65.
Should i manually download cc65, and if so, what command get's it installed then ?
It might be that you need to do the apt-get update, but it's easy enough to build cc65 from source: I did that earlier today. I downloaded and unpacked the zip file from https://github.com/cc65/cc65, then ran 'make' on the top level directory.

Now, installing it is potentially another matter... we could go down a number of rabbit holes here. What I sometimes do is

$ env PATH=/path/to/tool/bin:$PATH command line

so for example

$ env PATH=/path/to/tool/bin:$PATH ca65

or

$ env PATH=/path/to/tool/bin:$PATH make

and that should work. It doesn't matter where your tool is, so long as you know where it is.

I don't know if it's easy to download and unpack a zip file in such a way that bash can see the results. You might do it from the command line:

$ wget http://example.com/path/to/file.zip
$ unzip file.zip
sepseel
Posts: 36
Joined: 05 Mar 2017

Re: Help using cc65

Post by sepseel »

So, thusfar i managed to locate the right folder, however when i try to run make on the top level diretroy, it gives me an error (ill just post everything it outputs)

GIT_SHA: N/A
ar65/add.c
make[1]: gcc: Command not found
make[1]: *** [../wrk/ar65/add.o] Error 127
make: *** [all] Error 2

then it ends.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Help using cc65

Post by BigEd »

Ah - you have no compilation tools! There must be a suitable apt-get to sort that out.

Try
sudo apt-get update
sudo apt-get install build-essential
sepseel
Posts: 36
Joined: 05 Mar 2017

Re: Help using cc65

Post by sepseel »

Yes, that worked. Now the make command has succesfully run.
Wat's next ?

Btw, i really appreciate your help!
leepivonka
Posts: 167
Joined: 15 Apr 2016

Re: Help using cc65

Post by leepivonka »

The Windows Snapshot mentioned at http://cc65.github.io/cc65/ under links contains prebuilt Windows executables.
sepseel
Posts: 36
Joined: 05 Mar 2017

Re: Help using cc65

Post by sepseel »

leepivonka wrote:
The Windows Snapshot mentioned at http://cc65.github.io/cc65/ under links contains prebuilt Windows executables.
I see, but how would i use those then ?
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Help using cc65

Post by BigEd »

Hmm, I may have led you astray with Jeff's EhBasic port. Although it is the right syntax for cc65, and we do get a binary from it, it may assume something about the machine it will run on - specifically, the presence of a monitor program.

Perhaps we need to a look ahead a bit. When you get EhBasic on board, how do you intend to interact with it? Presumably over the serial port? We need some minimum amount of code in the EEPROM to drive the serial port.

Is it worth reading more about Jeff's monitor? Or does your SBC design come with a machine monitor story?
sepseel
Posts: 36
Joined: 05 Mar 2017

Re: Help using cc65

Post by sepseel »

Yes, i was planning on using serial to interact witch my system. I have this board: http://geoffg.net/terminal.html to output to a monitor over VGA. It also handles the keyboard, and outputs it as ASCII over serial.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Help using cc65

Post by BigEd »

It's probably a good idea to write a little Hello program - or to take someone's monitor code and convert that. At minimum, you need to know the address of the UART so your code can access it. You will probably need to write to a control register to initialise it.
sepseel
Posts: 36
Joined: 05 Mar 2017

Re: Help using cc65

Post by sepseel »

Sadly I don't know how to do any of those things, could you point me to a good source on how to do one of those things ?
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Help using cc65

Post by barrym95838 »

floobydust and 8-BIT might be among the most qualified members to answer questions about using the 6551. I was going to link you to Garth's pages (heck, I will anyway), but he seems to be (for the most part) a 6522 kind of guy. Please correct me if I'm wrong, Garth ...

Mike B.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Help using cc65

Post by GARTHWILSON »

barrym95838 wrote:
floobydust and 8-BIT might be among the most qualified members to answer questions about using the 6551. I was going to link you to Garth's pages (heck, I will anyway), but he seems to be (for the most part) a 6522 kind of guy. Please correct me if I'm wrong, Garth ...
I have a lot of material on the '22 simply because it's very versatile for so many uses. The '51 is of course more of a dedicated-purpose IC. However, I have the 6502-oriented RS-232 primer, although someone who's already familiar with RS-232 will be able to skim through most of it; and near the end of my interrupts primer, under the section title "Interrupt support for RS-232 receive" there's some example 6502 code for running an RS-232 receive buffer using a 6551, and on setting up the 6551 for the job.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Help using cc65

Post by BigEd »

sepseel wrote:
Sadly I don't know how to do any of those things, could you point me to a good source on how to do one of those things ?
OK, sounds like we need to slow down, backtrack, and do some reading. Jeff's projects contain a number of monitors. What you have is a serial port, so ideally we need to
- find a monitor program which uses a serial port
- read that code and start to understand what's going on
- modify the code to suit your hardware (which is to say, port the monitor to your machine)
- run the code on your hardware

In the meantime, I would suggest running something on Kowalski's simulator to get a feel for computing at this low level - it sounds like this might be new territory for you. But it's a lot of fun - I recommend exploring.

First thing I found, still in Jeff T's projects, is a tiny program which sprays characters out of a serial device (sometimes called ACIA, sometimes UART)
https://github.com/jefftranter/6502/blo ... et/demo1.s

It would not be a bad idea to get something like this to run. It's much like a Hello World.
sepseel
Posts: 36
Joined: 05 Mar 2017

Re: Help using cc65

Post by sepseel »

Ok, so quick update:

I have been playing around with the emulator, as you sugested. And I managed to get ehBASIC running, and executing a hello world program.
Doing this has made me a litle bit more understanding of the software aspect of 6502.

However, when i try to assemble the code from: https://github.com/jefftranter/6502/blo ... et/demo1.s
I get an error telling me this: ERROR E017: Missing constant value (number, label, function or '*'). ROW 18
What is this telling me ?
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Help using cc65

Post by BigEd »

The input on line 18 is
lda #%00011110 ; 2 stop bits, 8 data bits, internal clock, 9600 baud
and that's being rejected by your assembler. Most likely, the assembler doesn't understand the % syntax for binary. So, convert to hex: %00011110 is $1E and see if that works:
lda #$1E ; 2 stop bits, 8 data bits, internal clock, 9600 baud

Sooner or later it's going to be worth getting to grips with hex and binary. Indeed it's a common source of error to use one when you mean the other:
lda #20
and
lda #$20
are going to behave differently! Most of us here will use hex almost all the time. One or two have a strong preference for decimal. They are, I believe, missing out on a crucial technique...
Post Reply