Add dmesg, compilation fixes

This commit is contained in:
Michal Moskal 2017-07-01 12:43:10 +02:00
parent 33b9bba2a9
commit 2fe2f93abc
4 changed files with 24 additions and 9 deletions

View File

@ -1,6 +1,6 @@
include Makefile.inc include Makefile.inc
COMMON_FLAGS = -W -Wall -Wno-unused-parameter -Ipxtapp -fwrapv -fno-threadsafe-statics -Os COMMON_FLAGS = -W -Wall -Wno-unused-parameter -Ipxtapp -fwrapv -fno-threadsafe-statics -Os -mthumb
CFLAGS = $(COMMON_FLAGS) -std=c99 CFLAGS = $(COMMON_FLAGS) -std=c99
CXXFLAGS = $(COMMON_FLAGS) -std=c++11 -fno-rtti -fno-exceptions -fno-unwind-tables CXXFLAGS = $(COMMON_FLAGS) -std=c++11 -fno-rtti -fno-exceptions -fno-unwind-tables
LDFLAGS = -Wl,--gc-sections -Wl,--sort-common -Wl,--sort-section=alignment LDFLAGS = -Wl,--gc-sections -Wl,--sort-common -Wl,--sort-section=alignment
@ -10,6 +10,7 @@ LD = $(PREF)gcc
LIBSTDCPP = /usr/lib/gcc/arm-linux-gnueabi/4.9/libstdc++.a LIBSTDCPP = /usr/lib/gcc/arm-linux-gnueabi/4.9/libstdc++.a
EXE = bld/pxt-app.elf EXE = bld/pxt-app.elf
HEX = $(EXE:.elf=.hex)
DEPS = $(PXT_HEADERS) package.json Makefile Makefile.inc DEPS = $(PXT_HEADERS) package.json Makefile Makefile.inc
@ -19,6 +20,7 @@ $(EXE): $(PXT_OBJS)
$(LD) -o $(EXE) $(LDFLAGS) -Wl,-Map,$(EXE:.elf=.map) $(PXT_OBJS) $(LIBSTDCPP) -lm $(LD) -o $(EXE) $(LDFLAGS) -Wl,-Map,$(EXE:.elf=.map) $(PXT_OBJS) $(LIBSTDCPP) -lm
cp $(EXE) $(EXE:.elf=.full) cp $(EXE) $(EXE:.elf=.full)
$(PREF)strip $(EXE) $(PREF)strip $(EXE)
node -p 'require("fs").readFileSync("$(EXE)").toString("hex")' > $(HEX)
@ls -l $(EXE) @ls -l $(EXE)
clean: clean:

View File

@ -4,6 +4,18 @@
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <cstdarg>
void dmesg(const char *format, ...) {
char buf[500];
va_list arg;
va_start(arg, format);
vsnprintf(buf, sizeof(buf), format, arg);
va_end(arg);
fprintf(stderr, "DMESG: %s\n", buf);
}
namespace pxt { namespace pxt {
@ -73,5 +85,4 @@ uint32_t afterProgramPage() {
void dumpDmesg() { void dumpDmesg() {
// TODO // TODO
} }
} }

View File

@ -1,7 +1,7 @@
#ifndef __PXTCORE_H #ifndef __PXTCORE_H
#define __PXTCORE_H #define __PXTCORE_H
//void codal_dmesg(const char *format, ...); void dmesg(const char *fmt, ...);
#define DMESG(...) /* nothing */ #define DMESG dmesg
#endif #endif

View File

@ -3,9 +3,11 @@ let f = 0.5
let plus = i + f let plus = i + f
let minus = i - f let minus = i - f
let r = Math.random() while (true) {
let ri = Math.randomRange(5, 10) let r = Math.random()
serial.writeValue("R", r)
loops.pause(1000)
}
loops.forever(() => { //loops.forever(() => {
loops.pause(100) //})
})