To register and login, use your Google, Twitter, Facebook, LinkedIn, or OpenID credentials.

This is allowing us to stop most spam registrations. We've deleted most of the spam accounts that got through, and we're closely watching for more.

assembler tools

joanillojoanillo Posts: 5
edited November -1 in MeeBlip
I'm waiting for my order. Meanwhile, I'm surfing the source code and trying to understand everything. I wonder what utilities can I use with Linux to compile and execute de assembler code. I installed avra package (Ubuntu) that is a replacement of AVR Studio (more than 100 MB and only Windows-though it seems to work with wine).

With avra I have the error

meeblip.asm(60) : Error : Cannot find include file: m32def.inc

TIA, Joan Quintana-joanillo
«1

Comments

  • meeblipmeeblip Posts: 551 admin
    The AVR Studio code links an include file named "m32def" that provides register and setup information for the Mega32 processor. You'll need to determine what the equivalent file is for avra.

    You should also take a look at the AVR-AS assembler that's part of AVR-GCC.

    http://electrons.psychogenic.com/modules/arms/art/3/AVRGCCProgrammingGuide.php#asmwithavr-as
  • I'm still getting my micro-controller feet wet, and I haven't tried compiling the meeblip code yet, so this may not be good advice.  You might try replacing "m32def.inc" with "", Joan.  You'll definitely need to have the "avr-gcc" package installed.  In my limited experience, the most important / difficult first thing to get set up is a good Makefile.  Mostly just because I know the guy, I used the makefile from this project as a starting point:

    http://www.appliedplatonics.com/badge/

    You'll need to change a few parameters in there, like the microcontroller and the source file name (and presumably just comment out the CPU_FREQ line since that's in the code).  Also be sure to comment out the part that burns the fuses.  If you get the code compiled on Ubuntu, please let us know what worked for you, and I'll do the same!
  • First I want to say that I have nothing against AVR Studio, but normally I prefer light and command line tools. Finally I have AVR Studio installed with wine in Ubuntu 10.04, and I didn't found it easy (in my main hard disk it still doesn't run). Basically I followed the instructions in this pdf:

    http://www.avrfreaks.net/index.php?module=FreaksArticles&func=downloadArticle&id=601

    I uderstand that AVR Studio is the standard tool for Meeblip, and productivity is the most, and a graphical interface helps, of course (I'm not so old-fashioned and freak guy). But now that I have my Studio working, next week I want to give a chance to avra or avr-gcc (avr-as).
    At the moment the only thing that I can say is that, using avra, to override 'Cannot find include file: m32def.inc' the instruction is

    .DEVICE atmega16
    ;.INCLUDE "m32def.inc"
  • meeblipmeeblip Posts: 551 admin
    I think it's a path problem. I just did a filelist of the avra package, and it includes m32def.inc:

    http://packages.ubuntu.com/lucid/i386/avra/filelist
  • rediredi Posts: 17
    If I'm not mistaken, gcc-avr doesn't support AVR assembler, it uses the usual assembler dialects supported by GCC - but that means it can't be used for the meeblip source.

    Is there any chance that porting the code to C++ would result in a small enough object? That would allow people (like me) who don't know much assembler to hack on the code, and allow other compilers gcc-avr to be used.  I'm going to try porting it to C++ anyway, as I think it will help me learn AVR assembler, even if I don't end up using the ported version.
  • peterpeter Posts: 466 admin
    Ha, solving that problem by porting to C++ is hardly the most efficient solution. ;)

    Anyway, no, I don't believe you are correct - avr-as, part of the GNU toolchain, supports AVR Assembler, I think?
  • rediredi Posts: 17
    unfortunately avra can't parse the m32def.inc file it ships with: http://sourceforge.net/tracker/?func=detail&aid=2913672&group_id=55499&atid=477231
    so that rules out gcc-avr and avra ... hacking on meeblip on linux is looking tricky
  • peterpeter Posts: 466 admin
    Hi Jonathan - we're looking at this, as it impacts not only Linux but anyone using the GNU toolchain, so that we can have a common set of build instructions for hackers across Mac, Windows, and Linux. And I'm building myself on Linux and Mac, so I'm very interested in fixing this. I think you're right, that it is these include files that can throw things off for a project built with AVR Studio on Windows. Our goal for March would be to sort that problem and provide detailed instructions, as I do this myself. I don't think that porting to C is necessary to the solution -- gcc-avr is up to the job; we just have to adjust the code to make it work.
  • peterpeter Posts: 466 admin
    And, uh, yeah, I'm working through this myself, but looks like the answer will be here:
     http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=99527&start=0-- discussion of the same problem.

    http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=70673
    7:29 PMHUGE amount of documentation. So, I've got some bedtime reading as we work on this. ;)

    This is not in any way a MeeBlip issue. Most people doing this kind of development work on Windows. But at the same time, this was central to our goals with the MeeBlip project - we wanted to make sense of this kind of problem for people like you and (cough) me, using a single, tangible example and beginner-friendly documentation.

    Anyway, if you're game for solving this with me and James, we can probably take it off-forum while we work on it ... otherwise, expect a report back shortly. 

    And yeah, it won't be a Linux solution either; the same code will compile on any OS.
  • rediredi Posts: 17
    I'm pretty sure GNU as uses an incompatible assembler syntax.
    And indeed avr-as doesn't seem to support avr asm:
    ../inc/m32def.inc: Assembler messages:../inc/m32def.inc:47: Error: unknown pseudo-op: `.device'
    Web searches seem to confirm it's a different syntax, e.g. one of many results: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=452099

    This is one of the reasons I want to use a higher-level language :)
  • peterpeter Posts: 466 admin
    I don't think we're considering switching languages on the MeeBlip project in the near term, sorry. I think we'll evaluate adjusting the syntax to allow building with GNU.
  • peterpeter Posts: 466 admin
    Also, mate, you didn't read the explanation James gave above and I repeated above. You don't have to rewrite all the code; you just have to replace the included files for the Mega32 processor. 

    I can guarantee you that the choice of Assembly doesn't mandate the use of Windows and AVR Studio. GNU can do this. ;) And yes, I'm volunteering James and myself to work out how to do it, because I think it's important.
  • rediredi Posts: 17
    Hi, sorry for not refreshing before posting again, I missed your replies :)  I completely realise it's not a meeblip problem, I expected to have some hurdles if I wanted to hack my meeblip on Linux! I'm also not asking you to switch to C++, but I might try doing it myself, just for the learning experience ;)
    If I can help test or anything else involving the GNU toolchain let me know
  • peterpeter Posts: 466 admin
    Well, the idea is definitely not to have any hurdles for Linux hacking! That's my goal, at least! ;)

    Of course, you're welcome to do that, but it ... might not be the most fun! Anyway, hope to check back with more information in the next few days.
  • meeblipmeeblip Posts: 551 admin
    I might as well chime in. Swapping out the include file is easy. There are some other changes in syntax (primarily to do with difference in handling table pointers and port I/O addressing).

    It's not insurmountable by any means, although we have to make sure we don't end up having to support two code bases.
  • Hi,
    the avra supplied m32def.inc can be made to work by feeding it through the C pre-processor to expand the pre-processor directives in the there:

    cpp -x assembler-with-cpp -fno-working-directory /usr/share/avra/m32def.inc >m32def.inc

    It will need an edit to remove the first four lines (I can't remember the option to suppress those) and also to remove the overly long comment at  line 465.

    After that it works.
  • rediredi Posts: 17
    Cool, I'll try that this evening - thanks!
  • rediredi Posts: 17
    That worked, thanks!

    I ended up writing a makefile rule to regenerate the inc file for me, using a command similar to:
    cpp -P -x assembler-with-cpp /usr/share/avra-1.2.3/m32def.inc  | sed 's/\(;.\{80\}\).*/\1.../' > m32def.inc

    The -P preprocessor option suppresses the line markers on the first four lines.
    The sed command truncates the long comment
  • rediredi Posts: 17
    bah - the sed command got munged by the forum software, there are some missing backslashes before the (){} characters and before the '1'
    Second try ...
    sed 's/\\(;.\\{80\\}\\).*/\\1.../'
  • peterpeter Posts: 466 admin
  • peterpeter Posts: 466 admin
    Heh, okay, so you can in fact use code brackets like so -- "[code][/code][/code]"

    That sed code I'm not sure about. Which four lines do you need to surpress?
  • peterpeter Posts: 466 admin
    suppress, sorry, typo. :) 
    [code]
    [code]Paste your code like this in Noisepages.[/code]
    [/code]
  • peterpeter Posts: 466 admin
    James and I are trying this now, finally (James, like most AVR coders, has been using AVR Studio).

    I'm curious, those of you who did had it work, you didn't run into errors like this? I run the preprocessor as described above, but when I run avra on our code, I get these errors:
    [code]meeblip.asm(1774) : Error   : Found no label/variable/constant named SHIFTREG_1meeblip.asm(1831) : Error   : Found no label/variable/constant named DETUNEB_INTGmeeblip.asm(1831) : Error   : SRAM out of range (0 <= k <= 65535)meeblip.asm(2207) : Error   : Found no label/variable/constant named DETUNEB_INTGmeeblip.asm(2478) : Error   : Found no label/variable/constant named DETUNEB_INTGmeeblip.asm(2635) : Error   : Found no label/variable/constant named LFO_FRAC_Hmeeblip.asm(2761) : Error   : Found no label/variable/constant named LFO2_FRAC_Hmeeblip.asm(3034) : Error   : Found no label/variable/constant named MIDIPBEND_Hmeeblip.asm(3104) : Error   : Found no label/variable/constant named DETUNEB_INTGmeeblip.asm(3227) : Error   : Found no label/variable/constant named SHIFTREG_1meeblip.asm(3227) : Maximum error count reached. Exiting...done[/code]
  • d3rbyd3rby Posts: 7
    Avra will assemble the meeblip code ok on Mac OS X. The errors for unfound variables you were getting Peter are because avra does not like the comments ;\
    The errors for variables that are not found are on the lines following these comments. However, I didn't get the 'SRAM out of range' error.

    I ran the C preprocessor on m32def.inc with:
    cpp -P /m32def.inc > m32def.inc
    and removed the long comment on line 465.
    Removing the ;\ comments from meeblip.asm allowed it to assemble ok.
  • peterpeter Posts: 466 admin
    Yeah, sorry -- we worked out the comments problem. What we then found was that the compiler would build the code, but there's some other problem -- the firmware doesn't actually run on the MeeBlip. So we think there may be some other remaining, less visible issue.
  • meeblipmeeblip Posts: 551 admin
    As I recall, the problem was that the compiler didn't include the look-up tables. That should be relatively easy to resolve, just haven't wanted to dedicate an afternoon to figuring it out.
  • d3rbyd3rby Posts: 7
    Ok good to know about the look-up table issue. I'm waiting for an AVR programmer to arrive so I can download the hex and try it.

    For anyone else trying avra, the comment that doesn't work with avra didn't appear in my post - it's a single backslash following the comment semi-colon:
    [code] ;\ [/code]
  • d3rbyd3rby Posts: 7
    The comment didn't show in the code block either :-)
    How about this...
    [code] ;\\ [/code]
  • d3rbyd3rby Posts: 7
    one more try
    [code][/code] ;&#92 [\code]
  • d3rbyd3rby Posts: 7
    I've managed to assemble the meeblip firmware using avra on Mac OS X, and download it using avrdude using a Sparkfun Pocket AVR Programmer and it worked fine. Seems like the problem you describe is still to do with the comments with the backslash, here's what I did after the steps in earlier posts:

    After removing the semi-colon backslash comments that were causing errors, avra was producing a smaller binary than the current meeblip.hex in git. However it seems that other comments of this form get through without errors, but stop the assembly working properly - possibly the next line is treated as a comment.

    Removing all the comments followed by a backslash, including those with spaces between the semi-colon and backslash, increased the code size and avra showed:

    [code]
    Used memory blocks:   Data      :  Start = 0x0060, End = 0x014F, Length = 0x00F0   Code      :  Start = 0x0000, End = 0x091E, Length = 0x091F
    Assembly complete with no errors (2 warnings).Segment usage:   Code      :      2335 words (4670 bytes)   Data      :       240 bytes   EEPROM    :         0 bytes[/code]

    When the assembled hex is downloaded, avrdude shows that 4670 bytes has been written.
Sign In or Register to comment.