Skip to content

Error compiling on gnuc < 9, definition of alias uClibc. #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
df1083f
Take a copy of the minimal target
shenki Nov 15, 2016
3bb1e49
lm32: Basic port to the litex SoC with a lm32 CPU
shenki Nov 15, 2016
c68a934
lm32: Build .bin as default target
shenki Nov 20, 2016
8a48b7d
lm32: Update generated headers
katharosada Jan 19, 2017
0f2e4cb
lm32: include generated memory regions linker script
shenki Jan 31, 2017
156a60e
lm32: remove unused code from main
shenki Feb 1, 2017
7d84fc9
lm32: Attempt to implement ctrl+c interrupt
shenki Feb 1, 2017
6cbf13a
lm32: Fix exception keystroke handling
shenki Feb 1, 2017
3a6920d
lm32: remove unused defines
shenki Feb 5, 2017
8ffc6e1
lm32: Don't build in frozen modules yet
shenki Feb 5, 2017
9fa5e97
lm32: clean up the makefile
shenki Feb 5, 2017
565182e
lm32: Add longint implementation
shenki Feb 5, 2017
5e7a2ad
lm32: Add machine module
shenki Feb 5, 2017
1eaa8ea
gitignore: add vim .un~ undo files to ignore
shenki Feb 5, 2017
c89674e
lm32: Add litex module
shenki Feb 5, 2017
fd82bf6
lm32: Update generated headers
shenki Feb 5, 2017
4056858
lm32: Add leds module
shenki Feb 5, 2017
b8e5514
lm32: point to latest gcc directory
shenki Mar 15, 2017
015e480
lm32: link with GCC and remove hardcoded paths
shenki Mar 15, 2017
eff4d5e
lm32: update generated directory
shenki Mar 22, 2017
cc1dfd8
Removing generated files.
mithro Mar 29, 2017
67b6203
Working on Makefile.
mithro Mar 30, 2017
0e09cb0
Rename lm32 directory to litex
mithro Mar 30, 2017
b63852f
Better Makefile.
mithro Mar 30, 2017
72086fd
Adding support for local generated directory.
mithro Mar 31, 2017
782723b
Adding script to download gateware from the HDMI2USB prebuilt repo.
mithro Mar 31, 2017
21d255c
Allow litex leds to build with out cas
karl-malakoff Aug 7, 2017
52ff129
Merge pull request #4 from karl-malakoff/cas-leds-fix
shenki Aug 8, 2017
3d9bbb6
Fixed read function for cas leds
karl-malakoff Aug 8, 2017
452a2c3
Merge pull request #5 from karl-malakoff/led_read_fix
mithro Aug 12, 2017
7a4245d
Merge pull request #13 from mithro/master
mithro Aug 13, 2017
99d39a7
Update to MicroPython 1.9.4+ from micropython upstream
ewenmcneill Aug 27, 2018
74e683a
Move "litex" port to "ports/fupy"
ewenmcneill Aug 27, 2018
c6fb8fc
ports/fupy: Fix Makefile relative paths
ewenmcneill Aug 27, 2018
7e26f0c
Merge pull request #16 from ewenmcneill/ports-fupy
mithro Aug 27, 2018
04dce34
Enable floating point
Aug 28, 2018
fab5f75
Merge pull request #49 from whatnick/fupy_double
mithro Aug 28, 2018
53b48b7
Add support for LiteX boards which run their main program from flash.
cr1901 Sep 22, 2018
2a863c4
Update crt0 name and build rules to track LiteX changes. Copying crt0…
cr1901 Sep 26, 2018
4e7442f
Update common.h implementation to match what LiteX generates, fix Mak…
cr1901 Sep 26, 2018
b16bfc4
Make sure crt0 is linked first in output image.
cr1901 Sep 30, 2018
448f6ad
Merge pull request #51 from cr1901/litex-flash
ewenmcneill Oct 1, 2018
c7f43e5
Include files from litex.
mithro Aug 23, 2018
d24e3cb
Merge pull request #15 from mithro/riscv
mithro Oct 3, 2018
40e9364
Added switch support for MimasV2.
karl-malakoff Aug 8, 2017
3d09bf6
Fixed function header
karl-malakoff Aug 21, 2017
4071555
Merge pull request #6 from karl-malakoff/switches
mithro Oct 3, 2018
fea9721
ports/fupy: Ensure as sees custom headers too
ewenmcneill Aug 28, 2018
22de105
Merge pull request #50 from ewenmcneill/micropython-or1k
mithro Oct 3, 2018
8e14e5f
Improve include guards for boards which are missing some components o…
cr1901 Oct 29, 2018
e1202f3
Merge pull request #53 from cr1901/cas-guard
mithro Oct 29, 2018
cec3a4f
Fix compile on systems which copy micropython to RAM.
cr1901 Oct 30, 2018
886dbd2
Ensure riscv32 fupy port compiles on supported CPUs (not verified wor…
cr1901 Oct 30, 2018
7b0c438
fupy/litex.ld: Account for .srodata.* sections which may be generated…
cr1901 Nov 1, 2018
d2bd404
Merge pull request #54 from cr1901/riscv32
mithro Nov 1, 2018
5c32eab
Error compiling on gnuc < 9, definition of alias uClibc. Similar to h…
moaxey Aug 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
# VIM Swap Files
######################
*.swp
*.un~

# Build directory
######################
build/
generated/

# Test failure outputs
######################
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ STATIC void strn_print_strn(void *data, const char *str, size_t len) {
strn_print_env->remain -= len;
}

#if defined(__GNUC__) && !defined(__clang__)
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 9
// uClibc requires this alias to be defined, or there may be link errors
// when linkings against it statically.
int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias ("vsnprintf")));
Expand Down
140 changes: 140 additions & 0 deletions ports/fupy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
BUILDINC_DIRECTORY ?= .
ifeq ($(wildcard $(BUILDINC_DIRECTORY)/generated/variables.mak),)
define ERROR_MSG

$(BUILDINC_DIRECTORY)/generated/variables.mak not found.

MicroPython for LiteX requires these generated files to build. It
is important that the files match the gateware you are using and
are specific to each board / platform.

The LiteX generated files are found in build output directory
under "software/include/generated".

To allow MicroPython to find these files, you must do one of the
following;
* Set BUILDINC_DIRECTORY.
* Copy the files into a local generated directory.
* Run ./get-gateware.sh script (setting PLATFORM/TARGET value).

endef
$(error $(ERROR_MSG))
endif # no generated/variables.mak
include $(BUILDINC_DIRECTORY)/generated/variables.mak

include ../../py/mkenv.mk

# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h

# include py core make definitions
include ../../py/py.mk

CROSS_COMPILE ?= $(TRIPLE)-

INC += -I.
INC += -I../..
INC += -I../../lib/mp-readline
INC += -I$(BUILD)
INC += -I$(BUILDINC_DIRECTORY)

# Ensure assembler can also found our custom include files, for crt0
ASFLAGS += -I$(BUILDINC_DIRECTORY)

CFLAGS += $(CPUFLAGS)
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -ggdb $(COPT)
CFLAGS += -Og -Wdouble-promotion -Wall -Werror

ifneq ($(DEBUG), 1)
CFLAGS += -DNDEBUG
endif

ifeq ($(COPY_TO_MAIN_RAM), 1)
LDFLAGS += -nostartfiles -T litex.ld -Wl,[email protected] -Wl,--cref
else
LDFLAGS += -nostartfiles -T litex-flash.ld -Wl,[email protected] -Wl,--cref
endif

LDFLAGS += -L$(BUILDINC_DIRECTORY)
LIBS = -Wl,-lc -Wl,-lm

SRC_C = \
main.c \
uart.c \
isr.c \
modmachine.c \
modlitex.c \
litex_leds.c \
litex_switches.c \
lib/utils/stdout_helpers.c \
lib/utils/interrupt_char.c \
lib/utils/pyexec.c \
lib/libc/string0.c \
lib/mp-readline/readline.c

# FIXME: Should use crt0 from newlib? However it seems to cause memory access
# at 0x0

ifeq ($(COPY_TO_MAIN_RAM), 1)
CRT0_S ?= $(LIBBASE_DIRECTORY)/crt0-$(CPU).S
CRT0_O = $(BUILD)/crt0-$(CPU)-ctr.o
CRT0FLAGS =
else ifeq ($(EXECUTE_IN_PLACE), 1)
CRT0_S ?= $(LIBBASE_DIRECTORY)/crt0-$(CPU).S
CRT0_O = $(BUILD)/crt0-$(CPU)-xip.o
CRT0FLAGS = -DEXECUTE_IN_PLACE
else
$(error You need to define one of COPY_TO_MAIN_RAM or EXECUTE_IN_PLACE to 1)
endif

# CPU-specific overrides.
ifeq ($(CPU), picorv32)
# Extract the arch-specific flags, otherwise firmware won't link.
LDFLAGS += $(filter -march=% -mabi=%, $(CPUFLAGS))
# picorv32 needs a special assembly include to compile crt0.
ASFLAGS += -I$(SOC_DIRECTORY)/software/include/base
else ifeq ($(CPU), vexriscv)
LDFLAGS += $(filter -march=% -mabi=%, $(CPUFLAGS))
endif

# No extra assembly files for now.
SRC_S =

OBJ = $(CRT0_O) $(addprefix $(BUILD)/, $(SRC_S:.S=.o)) $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))

all: $(BUILD)/firmware.bin

# List of sources for qstr extraction
SRC_QSTR += $(SRC_C) $(SRC_LIB)

# crt0 override for normal assembler rule- needed to distinguish
# whether we need to assemble a crt0 that copies a data section to RAM from
# flash, or a crt0 that assumes a bootloader does it ahead of time.
$(CRT0_O): $(CRT0_S)
$(CC) -c $(ASFLAGS) $(CFLAGS) $(CRT0FLAGS) -o $@ $<

$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
$(ECHO) "MISC freezing bytecode"
$(Q)../tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@

$(BUILD)/firmware.elf: $(OBJ)
$(ECHO) "LINK $@"
$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@

$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
$(Q)$(OBJCOPY) -O binary $^ $(BUILD)/firmware.bin

# Run emulation build on a POSIX system with suitable terminal settings
run:
stty raw opost -echo
build/firmware.elf
@echo Resetting terminal...
# This sleep is useful to spot segfaults
sleep 1
reset

test: $(BUILD)/firmware.elf
$(Q)/bin/echo -e "print('hello world!', list(x+1 for x in range(10)), end='eol\\\\n')\\r\\n\\x04" | $(BUILD)/firmware.elf | tail -n2 | grep "^hello world! \\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\]eol"

include ../../py/mkrules.mk
35 changes: 35 additions & 0 deletions ports/fupy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# The minimal port

This port is intended to be a minimal MicroPython port that actually runs.
It can run under Linux (or similar) and on any STM32F4xx MCU (eg the pyboard).

## Building and running Linux version

By default the port will be built for the host machine:

$ make

To run a small test script do:

$ make run

## Building for an STM32 MCU

The Makefile has the ability to build for a Cortex-M CPU, and by default
includes some start-up code for an STM32F4xx MCU and also enables a UART
for communication. To build:

$ make CROSS=1

If you previously built the Linux version, you will need to first run
`make clean` to get rid of incompatible object files.

Building will produce the build/firmware.dfu file which can be programmed
to an MCU using:

$ make CROSS=1 deploy

This version of the build will work out-of-the-box on a pyboard (and
anything similar), and will give you a MicroPython REPL on UART1 at 9600
baud. Pin PA13 will also be driven high, and this turns on the red LED on
the pyboard.
11 changes: 11 additions & 0 deletions ports/fupy/csr-defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef CSR_DEFS__H
#define CSR_DEFS__H

#define CSR_MSTATUS_MIE 0x8

#define CSR_IRQ_MASK 0xBC0
#define CSR_IRQ_PENDING 0xFC0

#define CSR_DCACHE_INFO 0xCC0

#endif /* CSR_DEFS__H */
Binary file added ports/fupy/frozentest.mpy
Binary file not shown.
7 changes: 7 additions & 0 deletions ports/fupy/frozentest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
print('uPy')
print('a long string that is not interned')
print('a string that has unicode αβγ chars')
print(b'bytes 1234\x01')
print(123456789)
for i in range(4):
print(i)
27 changes: 27 additions & 0 deletions ports/fupy/get-gateware.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

PLATFORM="${PLATFORM:-mimasv2}"
TARGET="${TARGET:-base}"
CPU="${CPU:-lm32}"
BRANCH="${BRANCH:-master}"

GITHUB_URL=https://github.com/timvideos/HDMI2USB-firmware-prebuilt/

# Automatically figure out the latest revision
if [ "$REV" = "" ]; then
REV=$(svn ls $GITHUB_URL/trunk/archive/$BRANCH | sort | tail -n1 | sed -e's-/$--')
echo "Using revision $REV"
fi

# archive/master/v0.0.3-696-g2f815c1/minispartan6/base/lm32
BASE_DIR=archive/$BRANCH/$REV/$PLATFORM/$TARGET/$CPU

# Get the generated header files
svn export --force $GITHUB_URL/trunk/$BASE_DIR/software/include/generated | grep -v "^Exported"

# Get the flash file
#svn export --force $SVN_URL/flash.bin

# Get gateware and bios files (to allow image building)
#svn export --force $SVN_URL/gateware/top.bin gateware.bin
#svn export --force $SVN_URL/software/bios/bios.bin
52 changes: 52 additions & 0 deletions ports/fupy/hw/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef __HW_COMMON_H
#define __HW_COMMON_H

#include <stdint.h>

/* To overwrite CSR accessors, define extern, non-inlined versions
* of csr_read[bwl]() and csr_write[bwl](), and define
* CSR_ACCESSORS_DEFINED.
*/

#ifndef CSR_ACCESSORS_DEFINED
#define CSR_ACCESSORS_DEFINED

#ifdef __ASSEMBLER__
#define MMPTR(x) x
#else /* ! __ASSEMBLER__ */
#define MMPTR(x) (*((volatile unsigned int *)(x)))

static inline void csr_writeb(uint8_t value, uint32_t addr)
{
*((volatile uint8_t *)addr) = value;
}

static inline uint8_t csr_readb(uint32_t addr)
{
return *(volatile uint8_t *)addr;
}

static inline void csr_writew(uint16_t value, uint32_t addr)
{
*((volatile uint16_t *)addr) = value;
}

static inline uint16_t csr_readw(uint32_t addr)
{
return *(volatile uint16_t *)addr;
}

static inline void csr_writel(uint32_t value, uint32_t addr)
{
*((volatile uint32_t *)addr) = value;
}

static inline uint32_t csr_readl(uint32_t addr)
{
return *(volatile uint32_t *)addr;
}
#endif /* ! __ASSEMBLER__ */

#endif /* ! CSR_ACCESSORS_DEFINED */

#endif /* __HW_COMMON_H */
11 changes: 11 additions & 0 deletions ports/fupy/hw/ethmac_mem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __HW_ETHMAC_MEM_H
#define __HW_ETHMAC_MEM_H

#include <generated/mem.h>

#define ETHMAC_RX0_BASE ETHMAC_BASE
#define ETHMAC_RX1_BASE (ETHMAC_BASE+0x0800)
#define ETHMAC_TX0_BASE (ETHMAC_BASE+0x1000)
#define ETHMAC_TX1_BASE (ETHMAC_BASE+0x1800)

#endif
40 changes: 40 additions & 0 deletions ports/fupy/hw/flags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef __HW_FLAGS_H
#define __HW_FLAGS_H

#define UART_EV_TX 0x1
#define UART_EV_RX 0x2

#define DFII_CONTROL_SEL 0x01
#define DFII_CONTROL_CKE 0x02
#define DFII_CONTROL_ODT 0x04
#define DFII_CONTROL_RESET_N 0x08

#define DFII_COMMAND_CS 0x01
#define DFII_COMMAND_WE 0x02
#define DFII_COMMAND_CAS 0x04
#define DFII_COMMAND_RAS 0x08
#define DFII_COMMAND_WRDATA 0x10
#define DFII_COMMAND_RDDATA 0x20

#define ETHMAC_EV_SRAM_WRITER 0x1
#define ETHMAC_EV_SRAM_READER 0x1

#define CLKGEN_STATUS_BUSY 0x1
#define CLKGEN_STATUS_PROGDONE 0x2
#define CLKGEN_STATUS_LOCKED 0x4

#define DVISAMPLER_TOO_LATE 0x1
#define DVISAMPLER_TOO_EARLY 0x2

#define DVISAMPLER_DELAY_MASTER_CAL 0x01
#define DVISAMPLER_DELAY_MASTER_RST 0x02
#define DVISAMPLER_DELAY_SLAVE_CAL 0x04
#define DVISAMPLER_DELAY_SLAVE_RST 0x08
#define DVISAMPLER_DELAY_INC 0x10
#define DVISAMPLER_DELAY_DEC 0x20

#define DVISAMPLER_SLOT_EMPTY 0
#define DVISAMPLER_SLOT_LOADED 1
#define DVISAMPLER_SLOT_PENDING 2

#endif /* __HW_FLAGS_H */
Loading