Compile on Linux please!

Hi all.

Can someone tell me: how to compile asm and also C projects for PIC18f452 on Linux?

Thanx a lot

Hi QBAS,

Check out this link

    http://sdcc.sourceforge.net/

You can download the SDCC ‘C’ compiler and the gputils from this site. This compiler and utils provide support for the PIC chips. There are a couple of alternate methods for installing it on Linux depending on the flavor of Linux you have. The documentation with SDCC and gputils is fairly good. Although I don’t use Linux that often, this is the same compiler that is used on Windows so building applications on Linux should be fairly easy.

Hope this is what you are looking for  :slight_smile:

Regards,

Synapsys

Hi.

I’m no expert, but I’ll try to answer your questions:

For asm - for your own projects: gputils from http://gputils.sourceforge.net should work. But I think this isn’t useful for existing projects because Microchip assembler has different syntax. MPASM under Wine will work.

For C - I’d guess SDCC  2.5.0 (from http://sdcc.sourceforge.net/) will work. The instructions on http://www.ucapps.de/mios_c.html page are referring to install in WIN32 environment, but if you understand the general requirements to make it work You can make it also in Linux.

Moebius

Thank you very much.

Ok - this is what I need.

I will check gputils & SDCC ‘C’ compiler.

Previously I was trying install MPASM under Wine on FC4, but it never runs.

Maybe on another distro will be ok.

For asm - for your own projects: gputils from http://gputils.sourceforge.net should work. But I think this isn’t useful for existing projects because Microchip assembler has different syntax. MPASM under Wine will work.

So - if I use program Skeleton or modificate midibox64e under gputils program will not working?

(sorry for too much questions)

QBAS

Hi.

Previously I was trying install MPASM under Wine on FC4, but it never runs.

Hmm.. IF you have MPLAB IDE installed somewhere (on Win32), you could try only copying MPASMWIN.EXE and try using it under the wine.

So - if I use program Skeleton or modificate midibox64e under gputils program will not working?

That is what I’ve understood. GPASM will not compile sources made for MPASM but will give you bunch of errors because of the differences in the syntax.

Does anybody have better knowledge about this or am I wrong?

Moebius

hello Moebius

IF you have MPLAB IDE installed somewhere (on Win32), you could try only copying MPASMWIN.EXE and try using it under the wine.

Unfortunately not :(  I was not backuped an installed programs.

Maybe I will find somebody with Win32 for install and copy to my computer.

Ok I will try again, but thank you for many informations.

QBAS

Hi,

That is what I’ve understood. GPASM will not compile sources made for MPASM but will give you bunch of errors because of the differences in the syntax.

There are a few differences between MPASM and GPASM but they are somewhat insignificant. The original difficulty with MIDIbox code (MIOS and applications) with respect to GPASM was the macros that TK wrote. He used a feature in some macros that is not available in GPASM (e.g. passing an instruction to a macro as a parameter). I certainly don’t blame TK for this, as the feature is quite powerful. In and of itself, this is not a big problem since the macros can be expanded manually in the source code. This is a lot of work however and prone to errors. In the meantime, I believe that TK has modified the code to make it compatible with GPASM. (I am not certain about this so TK’s input is needed to be sure).

As an exercise in absurdity  ???, I wrote a Windows application last year that scanned every source module in MIOS and expanded all the macros into another set of source modules. Once I had done this I was able to build MIOS using GPASM. I don’t recommend this since you end up with a non-standard unsupported set of code. Like I said, an exercise in absurdity  :P.

Regards,

Synapsys

Hi all!

IF you have MPLAB IDE installed somewhere (on Win32), you could try only copying MPASMWIN.EXE and try using it under the wine.

Today my friend send me installed MPLAB, so now I can run it without installing!

Thank you guys from all my heart.

QBAS

Since i faced the same problem this week, i wrote some small sed script that replaces the problematic MACROs  in the source code:

replace-macros.sed

-------------------------------------------------------8<------------------------------------------------------------

1i;hey emacs, this is -*- asm -*-

/[1]*;/b #skip commented line

/^\s*\w*\s*MACRO/b #skip macro definitions

s/\<BIFSET\s*([^,]*)\s*,\s*([^,]*),\s*([^,]*)\s*,\s*(.*)/btfsc \1, \2, \3\n\t\4/g

s/\<BIFCLR\s*([^,]*)\s*,\s*([^,]*),\s*([^,]*)\s*,\s*(.*)/btfss \1, \2, \3\n\t\4/g

s/\<IFSET\s*([^,]*)\s*,\s*([^,]*),\s*(.*)/btfsc \1, \2\n\t\3/g

s/\<IFCLR\s*([^,]*)\s*,\s*([^,]*),\s*(.*)/btfss \1, \2\n\t\3/g

s/\<IFNEQ\s*([^,]*)\s*,\s*([^,]*),\s*(.*)/cpfseq \1, \2\n\t\3/g

s/\<IFLEQ\s*([^,]*)\s*,\s*([^,]*),\s*(.*)/cpfsgt \1, \2\n\t\3/g

s/\<IFGEQ\s*([^,]*)\s*,\s*([^,]*),\s*(.*)/cpfslt \1, \2\n\t\3/g

-------------------------------------------------------8<------------------------------------------------------------

fix-gpasm.sh:

-------------------------------------------------------8<------------------------------------------------------------

#!/bin/sh

for i in src/*.inc src/*.asm src/*.h;do

tr -d ‘\r’ < $i|sed -f replace-macros.sed >${i}_ && mv ${i}_ $i

done

-------------------------------------------------------8<------------------------------------------------------------

Now i just have to copy the new src/ directory if there is a new version, run fix-gpasm.sh and can compile the source native on linux with gpasm :slight_smile:

Greetings,

Sven.


  1. \t ↩︎

Nice work!!

I think this would be good on the wiki, would you mind if it was there? Many unix users could benefit from your skills.

Sven - Excellent Work!

As stryd_one already suggested this should be in the wiki.

Do You mind asking a favour: Could you write a little article to the wiki about compiling on linux with gpasm ect. with your code included. We could use Your expertise here.

You can log to http://wiki.midibox.org by using forum login/password combination.

Moebius

Good idea, i’ll add that to the wiki over the weekend. I think the sed script could also be improved, thats only “the-first-version-that-works-for-me”.

Greetings,

Sven.

This sed script is fantastic!! I try to make one with perl sometimes ago, because this is too boring to not be able to compile mios stuff with gpasm!

Thank you svens!!

i’ve created http://www.midibox.org/dokuwiki/doku.php?id=compiling_the_midibox_source_on_linux a few minutes ago, comments/improvements/suggestions are of course welcome 8)

Good on you mate! Thanks!  :smiley:

Hi

sorry but I`m not understood :stuck_out_tongue:

Is this link useful for C projects too? http://www.midibox.org/dokuwiki/doku.php?id=compiling_the_midibox_source_on_linux

Probably not. As it was said SDCC ‘C’ compiler is need.

But how to use it???

But how to use it?

Have people suddenly lost the ability to read? See the menu on the left, where it says ‘C Interface’? All the instructions are there.

<sigh>

-drin

I guess that drin views the forums in a frame… he means here: http://www.ucapps.de/mios_c.html

Thank you, thank you, thank you

You have opened my eyes, now I looking for infos with bigger focus. :o

No worries. You should always read ucapps.de, the forum, the wiki, the portal, and google for these things, many times you will find the answer there first, or at least something that will give you specific questions to ask here :slight_smile: