mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
add pioasm --version, and print version number in generated files (#2554)
Some checks are pending
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Waiting to run
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Waiting to run
Bazel presubmit checks / other-bazel-checks (push) Waiting to run
Check Configs / check-configs (push) Waiting to run
CMake / build (push) Waiting to run
Build on macOS / build (push) Waiting to run
Build on Windows / build (push) Waiting to run
Some checks are pending
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Waiting to run
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Waiting to run
Bazel presubmit checks / other-bazel-checks (push) Waiting to run
Check Configs / check-configs (push) Waiting to run
CMake / build (push) Waiting to run
Build on macOS / build (push) Waiting to run
Build on Windows / build (push) Waiting to run
* add pioasm --version, and print version number in generated files * Hook up pio version string in Bazel build --------- Co-authored-by: Armando Montanez <amontanez@google.com>
This commit is contained in:
parent
19904be31f
commit
d2cdf6c953
14 changed files with 98 additions and 9 deletions
|
|
@ -18,6 +18,10 @@
|
|||
* parameters.
|
||||
*
|
||||
* For fuller descriptions of the instructions in question see the "RP2040 Datasheet"
|
||||
*
|
||||
* NOTE: These are helper functions for the raw instruction encoding, and thus
|
||||
* only provide support for pins numbered 0-31. You should adjust your encoding
|
||||
* according to your expected GPIO_BASE (see \ref pio_set_gpio_base)
|
||||
*/
|
||||
|
||||
// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_PIO_INSTRUCTIONS, Enable/disable assertions in the PIO instructions, type=bool, default=0, group=pio_instructions
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
load("//bazel:defs.bzl", "compatible_with_rp2")
|
||||
load("//bazel:defs.bzl", "compatible_with_rp2", "pico_generate_pio_header")
|
||||
load("//bazel/util:transition.bzl", "kitchen_sink_test_binary")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
|
@ -21,6 +21,11 @@ cc_library(
|
|||
includes = ["."],
|
||||
)
|
||||
|
||||
pico_generate_pio_header(
|
||||
name = "trivial_pio_test",
|
||||
srcs = ["trivial.pio"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "kitchen_sink_common",
|
||||
testonly = True,
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ pico_set_program_name(kitchen_sink "Wombat tentacles")
|
|||
pico_add_extra_outputs(kitchen_sink)
|
||||
target_compile_definitions(kitchen_sink PRIVATE KITCHEN_SINK_ID="regular binary")
|
||||
|
||||
if (TARGET hardware_pio)
|
||||
pico_generate_pio_header(kitchen_sink ${CMAKE_CURRENT_LIST_DIR}/trivial.pio)
|
||||
endif()
|
||||
|
||||
add_executable(kitchen_sink_extra_stdio ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
|
||||
if (COMMAND suppress_tinyusb_warnings)
|
||||
# Explicitly suppress warnings in TinyUSB files which have them (this has to be done
|
||||
|
|
|
|||
3
test/kitchen_sink/trivial.pio
Normal file
3
test/kitchen_sink/trivial.pio
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.program trivial
|
||||
|
||||
out pins, 1
|
||||
|
|
@ -34,6 +34,7 @@ if (NOT TARGET pioasm)
|
|||
"-DCMAKE_RULE_MESSAGES=OFF" # quieten the build
|
||||
"-DCMAKE_INSTALL_MESSAGE=NEVER" # quieten the install
|
||||
CMAKE_CACHE_ARGS "-DPIOASM_EXTRA_SOURCE_FILES:STRING=${PIOASM_EXTRA_SOURCE_FILES}"
|
||||
"-DPIOASM_VERSION_STRING:STRING=${PICO_SDK_VERSION_STRING}"
|
||||
BUILD_ALWAYS 1 # force dependency checking
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
# TODO: No support for building the parser.
|
||||
|
|
@ -19,6 +21,7 @@ cc_library(
|
|||
"pio_disassembler.h",
|
||||
"pio_enums.h",
|
||||
"pio_types.h",
|
||||
":version",
|
||||
],
|
||||
copts = select({
|
||||
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
|
||||
|
|
@ -63,6 +66,15 @@ cc_library(
|
|||
alwayslink = True,
|
||||
)
|
||||
|
||||
expand_template(
|
||||
name = "version",
|
||||
template = "version.h.in",
|
||||
substitutions = {
|
||||
"${PIOASM_VERSION_STRING}": module_version() if module_version() != None else "0.0.1-WORKSPACE",
|
||||
},
|
||||
out = "gen/version.h",
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "pioasm",
|
||||
deps = [
|
||||
|
|
|
|||
|
|
@ -41,7 +41,13 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND
|
|||
target_compile_options(pioasm PRIVATE -Wno-psabi)
|
||||
endif()
|
||||
|
||||
target_include_directories(pioasm PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/gen)
|
||||
if (NOT PIOASM_VERSION_STRING)
|
||||
message(FATAL_ERROR "PIOASM_VERSION_STRING must be provided when building pioasm")
|
||||
endif()
|
||||
|
||||
configure_file( ${CMAKE_CURRENT_LIST_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
|
||||
|
||||
target_include_directories(pioasm PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/gen ${CMAKE_BINARY_DIR})
|
||||
|
||||
if (MSVC OR
|
||||
(WIN32 AND NOT MINGW AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")))
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "output_format.h"
|
||||
#include "pio_disassembler.h"
|
||||
#include "version.h"
|
||||
|
||||
struct ada_output : public output_format {
|
||||
struct factory {
|
||||
|
|
@ -97,7 +99,9 @@ struct ada_output : public output_format {
|
|||
FILE *out = open_single_output(destination);
|
||||
if (!out) return 1;
|
||||
|
||||
header(out, "This file is autogenerated by pioasm; do not edit!", 0);
|
||||
std::stringstream header_string;
|
||||
header_string << "This file is autogenerated by pioasm version " << PIOASM_VERSION_STRING << "; do not edit!";
|
||||
header(out, header_string.str(), 0);
|
||||
fprintf(out, "pragma Style_Checks (Off);\n\n");
|
||||
fprintf(out, "with RP.PIO;\n\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "output_format.h"
|
||||
#include "pio_disassembler.h"
|
||||
#include "version.h"
|
||||
|
||||
struct c_sdk_output : public output_format {
|
||||
struct factory {
|
||||
|
|
@ -66,7 +68,9 @@ struct c_sdk_output : public output_format {
|
|||
FILE *out = open_single_output(destination);
|
||||
if (!out) return 1;
|
||||
|
||||
header(out, "This file is autogenerated by pioasm; do not edit!");
|
||||
std::stringstream header_string;
|
||||
header_string << "This file is autogenerated by pioasm version " << PIOASM_VERSION_STRING << "; do not edit!";
|
||||
header(out, header_string.str());
|
||||
|
||||
fprintf(out, "#pragma once\n");
|
||||
fprintf(out, "\n");
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "output_format.h"
|
||||
#include "pio_disassembler.h"
|
||||
#include "version.h"
|
||||
|
||||
struct go_output : public output_format {
|
||||
struct factory {
|
||||
|
|
@ -63,8 +65,10 @@ struct go_output : public output_format {
|
|||
FILE *out = open_single_output(destination);
|
||||
if (!out) return 1;
|
||||
|
||||
header(out, "Code generated by pioasm; DO NOT EDIT.");
|
||||
|
||||
std::stringstream header_string;
|
||||
header_string << "This file is autogenerated by pioasm version " << PIOASM_VERSION_STRING << "; do not edit!";
|
||||
header(out, header_string.str());
|
||||
|
||||
// First we give priority to user's code blocks since
|
||||
// 1. In Go our imports always precede our code.
|
||||
// 2. We give users the freedom to use their own PIO implementation.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <iostream>
|
||||
#include "pio_assembler.h"
|
||||
#include "version.h"
|
||||
|
||||
#define DEFAULT_OUTPUT_FORMAT "c-sdk"
|
||||
|
||||
|
|
@ -24,6 +25,7 @@ void usage() {
|
|||
}
|
||||
std::cerr << " -p <output_param> add a parameter to be passed to the output format generator" << std::endl;
|
||||
std::cerr << " -v <version> specify the default PIO version (0 or 1)" << std::endl;
|
||||
std::cerr << " --version print pioasm version information" << std::endl;
|
||||
std::cerr << " -?, --help print this help and exit\n";
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +68,9 @@ int main(int argc, char *argv[]) {
|
|||
} else if (argv[i] == std::string("-?") || argv[i] == std::string("--help")) {
|
||||
usage();
|
||||
return 1;
|
||||
} else if (argv[i] == std::string("--version")) {
|
||||
std::cout << "pioasm version: " << PIOASM_VERSION_STRING << std::endl;
|
||||
return 0;
|
||||
} else {
|
||||
std::cerr << "error: unknown option " << argv[i] << std::endl;
|
||||
res = 1;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include "output_format.h"
|
||||
#include "pio_disassembler.h"
|
||||
#include "version.h"
|
||||
|
||||
struct python_output : public output_format {
|
||||
struct factory {
|
||||
|
|
@ -61,7 +61,9 @@ struct python_output : public output_format {
|
|||
FILE *out = open_single_output(destination);
|
||||
if (!out) return 1;
|
||||
|
||||
header(out, "This file is autogenerated by pioasm; do not edit!");
|
||||
std::stringstream header_string;
|
||||
header_string << "This file is autogenerated by pioasm version " << PIOASM_VERSION_STRING << "; do not edit!";
|
||||
header(out, header_string.str());
|
||||
|
||||
fprintf(out, "import rp2\n");
|
||||
fprintf(out, "from machine import Pin");
|
||||
|
|
|
|||
|
|
@ -50,4 +50,23 @@ wait gpio 40
|
|||
wait 0 jmppin
|
||||
wait 0 jmppin + 3
|
||||
mov x, !x
|
||||
.word 0x1234
|
||||
.word 0x1234
|
||||
|
||||
|
||||
.program prev_next
|
||||
.pio_version 1
|
||||
wait 0 irq prev 0 ; Wait for IRQ0
|
||||
irq prev clear 0 ; Clear IRQ0
|
||||
irq clear 0 ; Clear IRQ0
|
||||
wait 0 irq next 0 ; Wait for IRQ0
|
||||
irq next clear 0 ; Clear IRQ0
|
||||
|
||||
.program wee
|
||||
.pio_version 1
|
||||
wait 0 gpio 15
|
||||
wait 0 gpio 31
|
||||
|
||||
.program wee2
|
||||
.pio_version 1
|
||||
wait 0 gpio 31
|
||||
wait 0 gpio 47
|
||||
|
|
|
|||
16
tools/pioasm/version.h.in
Normal file
16
tools/pioasm/version.h.in
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
// ---------------------------------------
|
||||
// THIS FILE IS AUTOGENERATED; DO NOT EDIT
|
||||
// ---------------------------------------
|
||||
|
||||
#ifndef _PIOASM_VERSION_H
|
||||
#define _PIOASM_VERSION_H
|
||||
|
||||
#define PIOASM_VERSION_STRING "${PIOASM_VERSION_STRING}"
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue