ckormanyos / real-time-cpp

Source code for the book Real-Time C++, by Christopher Kormanyos
Boost Software License 1.0
601 stars 167 forks source link

Can the ref_app be built on mac host and run on the board? #8

Closed ckormanyos closed 4 years ago

ckormanyos commented 10 years ago

Some readers are using the ref_app on a mac host. Does the ref_app even work on a mac host, or does some adaption need to occur?

JamesStokebrand commented 10 years ago

I'm replying here because it is more appropriate than the other thread.

I made some modifications to the build files: FILE: ref_app/target/app/make/app_make.gmk

FILE: ref_app/target/micros/avr/make/avr_flags.gmk

Able to successfully compile the ref_app on a Mac using the avr-gcc tool-chain. Put together a ATmega328p reference circuit with an LED on a bread board and successfully flashed the hex file. The LED blinked, so I believe the program ran successfully.

ckormanyos commented 10 years ago

Thanks for the information James.

Were you able to to use GNUmake in its native form on the mac for the ref_app?

Yes. The HEX manipulation program is yet another open issue. Its purpose is to manipulate HEX files via things like adding fill bytes, patching memory sections together, computing CRC and hash data integrity checks and putting them in code for ROM/RAM integrity checks, etc.

Eventually, I would like to replace the executable file with portable sources for HEX-manipulation.

Cheers, Chris.

JamesStokebrand commented 10 years ago

Yes, I'm still using the GNU makefiles provided in the project with the following changes:

Used the following build command:

make -f target/app/make/app_make.gmk rebuild

This build successfully with one error related to the HexManip.exe file:

make: tools/generic/hex_tools/HexManip.exe: Permission denied
make: [bin/ref_app_flash.hex] Error 1 (ignored)

Here is the git diff for these changes:

diff --git a/ref_app/target/app/make/app_make.gmk b/ref_app/target/app/make/app_make.gmk
index f25aa17..b172a36 100644
--- a/ref_app/target/app/make/app_make.gmk
+++ b/ref_app/target/app/make/app_make.gmk
@@ -30,9 +30,10 @@ COMPILER_DIRECTORY = gcc-$(GCC_VERSION)-$(GCC_TARGET)
 PATH_TOOLS           = tools
 PATH_TOOLS_UTIL      = $(PATH_TOOLS)\Util
 PATH_TOOLS_MINGW     = $(PATH_TOOLS_UTIL)\MinGW\msys\1.0
-PATH_TOOLS_MINGW_BIN = $(PATH_TOOLS_MINGW)\bin
-PATH_TOOLS_CC        = $(PATH_TOOLS_MINGW)\local\$(COMPILER_DIRECTORY)\bin
+PATH_TOOLS_MINGW_BIN = /bin
+PATH_TOOLS_CC        = /opt/local/bin

+TGT                  = avr
 PATH_APP             = src
 PATH_TGT             = target/micros/$(TGT)
 PATH_APP_MAKE        = target/app/make
@@ -91,23 +92,23 @@ VPATH := $(sort $(dir $(FILES_TMP)))
 # ------------------------------------------------------------------------------
 # Development tools
 # ------------------------------------------------------------------------------
-AR        = $(PATH_TOOLS_CC)\$(GCC_TARGET)-ar.exe
-AS        = $(PATH_TOOLS_CC)\$(GCC_TARGET)-g++.exe
-CC        = $(PATH_TOOLS_CC)\$(GCC_TARGET)-g++.exe
-CL        = $(PATH_TOOLS_CC)\$(GCC_TARGET)-g++.exe
-CPPFILT   = $(PATH_TOOLS_CC)\$(GCC_TARGET)-c++filt.exe
-HEX_MANIP = $(PATH_TOOLS)\generic\hex_tools\HexManip.exe
-NM        = $(PATH_TOOLS_CC)\$(GCC_TARGET)-nm.exe
-OBJDUMP   = $(PATH_TOOLS_CC)\$(GCC_TARGET)-objdump.exe
-OBJCOPY   = $(PATH_TOOLS_CC)\$(GCC_TARGET)-objcopy.exe
-READELF   = $(PATH_TOOLS_CC)\$(GCC_TARGET)-readelf.exe
-SIZE      = $(PATH_TOOLS_CC)\$(GCC_TARGET)-size.exe
-
-ECHO      = $(PATH_TOOLS_MINGW_BIN)\echo.exe
-MAKE      = $(PATH_TOOLS_MINGW_BIN)\make.exe
-MKDIR     = $(PATH_TOOLS_MINGW_BIN)\mkdir.exe
-RM        = $(PATH_TOOLS_MINGW_BIN)\rm.exe
-SED       = $(PATH_TOOLS_MINGW_BIN)\sed.exe
+AR        = $(PATH_TOOLS_CC)/$(GCC_TARGET)-ar
+AS        = $(PATH_TOOLS_CC)/$(GCC_TARGET)-g++
+CC        = $(PATH_TOOLS_CC)/$(GCC_TARGET)-g++
+CL        = $(PATH_TOOLS_CC)/$(GCC_TARGET)-g++
+CPPFILT   = $(PATH_TOOLS_CC)/$(GCC_TARGET)-c++filt
+HEX_MANIP = $(PATH_TOOLS)/generic/hex_tools/HexManip.exe
+NM        = $(PATH_TOOLS_CC)/$(GCC_TARGET)-nm
+OBJDUMP   = $(PATH_TOOLS_CC)/$(GCC_TARGET)-objdump
+OBJCOPY   = $(PATH_TOOLS_CC)/$(GCC_TARGET)-objcopy
+READELF   = $(PATH_TOOLS_CC)/$(GCC_TARGET)-readelf
+SIZE      = $(PATH_TOOLS_CC)/$(GCC_TARGET)-size
+
+ECHO      = $(PATH_TOOLS_MINGW_BIN)/echo
+MAKE      = /usr/bin/make
+MKDIR     = $(PATH_TOOLS_MINGW_BIN)/mkdir
+RM        = $(PATH_TOOLS_MINGW_BIN)/rm
+SED       = /usr/bin/sed

 # ------------------------------------------------------------------------------
diff --git a/ref_app/target/micros/avr/make/avr_flags.gmk b/ref_app/target/micros/avr/make/avr_flags.gmk
index f74e641..371f447 100644
--- a/ref_app/target/micros/avr/make/avr_flags.gmk
+++ b/ref_app/target/micros/avr/make/avr_flags.gmk
@@ -9,8 +9,8 @@
 # compiler flags for the target architecture
 # ------------------------------------------------------------------------------

-GCC_VERSION   = 4.7.2
-GCC_TARGET    = avr-unknown-elf
+GCC_VERSION   = 4.8.2
+GCC_TARGET    = avr

 TGT_STL_DIR   = STL
 TGT_STL_DEFS  =
thzoechbauer commented 9 years ago

Hello Chris!

I'm using Windows but have a problem with hexmanip.exe too: it is missing and I can't figure out where to download it? Do I have to execute hexmanip.exe on the hex-file or can I comment this line out of app_make.gmk?

Thanks, Tom

ckormanyos commented 9 years ago

Thanks Tom. Please just comment out the line. The presence of the line is actually a bug. Sorry, I thought had already corrected it. I will correct it next week. - Chris

ckormanyos commented 9 years ago

The hex-manip line has been removed from the build script. But this breaks raspi and beagle bone builds of object binaries. Therefore, make a new issue for the creation of a new generic hex-manip facility.

ckormanyos commented 4 years ago

The GNUmake scripts have been extended to include *nix compatibility. There are also new CMake scripts that probably run on the above-mentioned host.