buserror / simavr

simavr is a lean, mean and hackable AVR simulator for linux & OSX
GNU General Public License v3.0
1.58k stars 368 forks source link

Supported cores on Mac OS 10.8 #20

Closed snoremac closed 6 years ago

snoremac commented 11 years ago

Hi,

Used simavr about 12 months ago when I was running 10.6 (Snow Leopard) and found it really useful.

Doing some arduino stuff again on 10.8 (Mountain Lion), but when I compile and execute run_avr I get:

Usage: run_avr [-t] [-g] [-v] [-m <device>] [-f <frequency>] firmware
       -t: Run full scale decoder trace
       -g: Listen for gdb connection on port 1234
       -ff: Load next .hex file as flash
       -ee: Load next .hex file as eeprom
       -v: Raise verbosity level (can be passed more than once)
   Supported AVR cores:

(i.e. no AVR cores supported).

I've checked out sim_core_decl.h and related files and all the avr kinds are declared. Can't find anything obviously missing.

I did tweak Makefile.common a bit for my avr-gcc toolchain, but everything compiles fine and the tests pass, so I'm pretty sure I got it right.

Simavr revision 4e64e8b, compiling with Apple clang 4.1.

Any advice appreciated.

thanks,

Cam

bsekisser commented 11 years ago

What was the command line you issued? IIRC you may likely need to supply the -m and -f switches.

example: run_avr -m atmega168 -f 2000000 someromname.elf

snoremac commented 11 years ago

A command of that form gives me:

$ simavr -m atmega328 -f 16000000L test.elf

Loaded 10482 .text Loaded 580 .data avr_make_mcu_by_name: AVR 'atmega328' not known simavr: AVR 'atmega328' not known

bsekisser commented 11 years ago

First I ask for you to see to it that you have the latest commits...

RECOMPILE & TEST. Each time do a clean make to help rule out and residual data contaminating the run.

After that make sure CONFIG_SIMAVR_TRACE is disabled... in 'Makefile.common' I believe. Then in sim_elf.h? Find and disable ELF_SYMBOLS... Defining ELF_SYMBOLS 0 above the block should do the trick.

RECOMPILE & TEST.

Get back to me with the results.

yoogx commented 11 years ago

Hi,

I got the exact same issue with simavr (using commit 4a297c69463eeba8646c6cee5b353a0b36995b45).

Problem was that CONFIG_CORES was not set. After hacking makefile to define it in sim_core_decl.h, everything worked fine. But this macro would not make sense.

Actually, it looks like the guilty guy is some script you use in the makefile to build it

Here is sim_core_decl.h generated on my mac

if CONFIG_CORES//SIM_MEGA48

extern avr_kind_t mega48;

endif

while your code expects

simavr/sim_core_config.h:#define CONFIG_MEGA48 1

Here is a small patch to solve this, that proved to work (in sime_core_decl.h target)

Question is: is it OSX shell that makes upper incorrect? is this path valid? Any feedback appreciated.

buserror commented 11 years ago

Could you post the badly generated file here? it works on my machine, it's rather bizarre...

yoogx commented 11 years ago

// Autogenerated do not edit

ifndef SIM_CORE_DECL_H

define SIM_CORE_DECL_H

include "sim_core_config.h"

if CONFIG_CORES//SIM_90USB162

extern avr_kind_t usb162;

endif

if CONFIG_CORES//SIM_MEGA128

extern avr_kind_t mega128;

endif

if CONFIG_CORES//SIM_MEGA1280

extern avr_kind_t mega1280;

endif

if CONFIG_CORES//SIM_MEGA1281

extern avr_kind_t mega1281;

endif

if CONFIG_CORES//SIM_MEGA164

extern avr_kind_t mega164;

endif

if CONFIG_CORES//SIM_MEGA168

extern avr_kind_t mega168;

endif

if CONFIG_CORES//SIM_MEGA324

extern avr_kind_t mega324;

endif

if CONFIG_CORES//SIM_MEGA328

extern avr_kind_t mega328;

endif

if CONFIG_CORES//SIM_MEGA48

extern avr_kind_t mega48;

endif

if CONFIG_CORES//SIM_MEGA644

extern avr_kind_t mega644;

endif

if CONFIG_CORES//SIM_MEGA8

extern avr_kind_t mega8;

endif

if CONFIG_CORES//SIM_MEGA88

extern avr_kind_t mega88;

endif

if CONFIG_CORES//SIM_TINY13

extern avr_kind_t tiny13;

endif

if CONFIG_CORES//SIM_TINY2313

extern avr_kind_t tiny2313;

endif

if CONFIG_CORES//SIM_TINY24

extern avr_kind_t tiny24;

endif

if CONFIG_CORES//SIM_TINY25

extern avr_kind_t tiny25;

endif

if CONFIG_CORES//SIM_TINY44

extern avr_kind_t tiny44;

endif

if CONFIG_CORES//SIM_TINY45

extern avr_kind_t tiny45;

endif

if CONFIG_CORES//SIM_TINY84

extern avr_kind_t tiny84;

endif

if CONFIG_CORES//SIM_TINY85

extern avr_kind_t tiny85;

endif

extern avr_kind_t * avr_kind[];

ifdef AVR_KIND_DECL

avr_kind_t * avr_kind[] = {

if CONFIG_CORES//SIM_90USB162

&usb162,

endif

if CONFIG_CORES//SIM_MEGA128

&mega128,

endif

if CONFIG_CORES//SIM_MEGA1280

&mega1280,

endif

if CONFIG_CORES//SIM_MEGA1281

&mega1281,

endif

if CONFIG_CORES//SIM_MEGA164

&mega164,

endif

if CONFIG_CORES//SIM_MEGA168

&mega168,

endif

if CONFIG_CORES//SIM_MEGA324

&mega324,

endif

if CONFIG_CORES//SIM_MEGA328

&mega328,

endif

if CONFIG_CORES//SIM_MEGA48

&mega48,

endif

if CONFIG_CORES//SIM_MEGA644

&mega644,

endif

if CONFIG_CORES//SIM_MEGA8

&mega8,

endif

if CONFIG_CORES//SIM_MEGA88

&mega88,

endif

if CONFIG_CORES//SIM_TINY13

&tiny13,

endif

if CONFIG_CORES//SIM_TINY2313

&tiny2313,

endif

if CONFIG_CORES//SIM_TINY24

&tiny24,

endif

if CONFIG_CORES//SIM_TINY25

&tiny25,

endif

if CONFIG_CORES//SIM_TINY44

&tiny44,

endif

if CONFIG_CORES//SIM_TINY45

&tiny45,

endif

if CONFIG_CORES//SIM_TINY84

&tiny84,

endif

if CONFIG_CORES//SIM_TINY85

&tiny85,

endif

NULL

};

endif

endif

yoogx commented 11 years ago

As explained, the CONFIGCORES//SIM<...> is wrong (AFAICT)

Note I just test with CentOS 6, bash as a shell, and it works as you expect it. (Well, I have to import Arduino and tweak the makefiles since CentOS has an old avr-gcc, but its another story)

For the records, I also have make 3.8.1 on the both OS X and Centos 6

bsekisser commented 11 years ago

OS X is *BSD based whereas CentOS that I can tell is mainstream Linux... Don't know how it still stands but back at 10.3.x and earlier I spent a lot of time tweaking makefiles, source and even recompiling parts of the system to make things compile... Yes you can compare but not necessarily think it to be equal. I am hoping you know that already but putting it out there if you don't.

Somebody else already commented above about having issues going from 10.6 to 10.8... What OS X version you using? buserror?

Using debian here... make 3.81... so I don't think that is an issue... Shell?

buserror commented 11 years ago

it's definitely not a make problem; I use bash built in string substitution in the expression, but I'm pretty sure that expression has been there fro a long time too. It's entirely bizare, it's like they don't have the 'real' bash?

yoogx commented 11 years ago

Almost, they manage to have a bash version older than CentSO 6 ;) See OS X 10.8.3 macbookair-hugues-w-r% uname -a Darwin macbookair-hugues.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 macbookair-hugues-w-r% bash --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12) Copyright (C) 2007 Free Software Foundation, Inc.

CentOS 6.3

[hugues@localhost]~% uname -a Linux localhost.localdomain 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [hugues@localhost]~% bash --version GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

I'll try with bash from Mac Ports and report, probably later this week

lucaspiller commented 10 years ago

Just a reminder this issue is still present on OS X 10.9:

$ uname -a
Darwin Maiz.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64

$ bash --version
GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
andyhoffy commented 9 years ago

Yeah, I am still seeing the issue as well. The suggested change still works on 10.9, but I don't have a linux box to check if the change is backwards-compatible. In simavr/Makefile:

@@ -189,7 +189,7 @@
    for core in $$(grep -r avr_kind_t cores/|awk -F '[ :]' '{print $$1 "=" $$3;}') ; do \
        file=$${core/=*}; global=$${core/*=}; \
        upper=$${file/cores\/sim_}; upper=$${upper/.c}; \
-       upper=$$(echo $$upper|tr '[a-z]' '[A-Z]'); \
+       upper=$$(echo $$global|tr '[a-z]' '[A-Z]'); \
        decl+="#if CONFIG_$$upper\nextern avr_kind_t $$global;\n#endif\n"; \
        array+="#if CONFIG_$$upper\n\t&$$global,\n#endif\n"; \
    done ; \
ghost commented 9 years ago

I had the same problem on MacOS 10.8.5. The above Makefile change worked for me. Thanks.

dylanmckay commented 7 years ago

I've had this problem on Arch Linux with the zsh shell.

$ uname -a
Linux dylan-pc 4.11.7-1-ARCH #1 SMP PREEMPT Sat Jun 24 09:07:09 CEST 2017 x86_64 GNU/Linux

The fix also worked for me.

buserror commented 6 years ago

Solved long ago