Skip to content

Commit

Permalink
Release v4.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Prusa Research authored and dragomirecky committed Jul 4, 2023
1 parent 415f74a commit 10b2c5d
Show file tree
Hide file tree
Showing 21 changed files with 144 additions and 79 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include(ExternalProject)
include(cmake/Utilities.cmake)
include(cmake/GetGitRevisionDescription.cmake)
include(cmake/ProjectVersion.cmake)
include(cmake/CheckRemotes.cmake)
include(cmake/Littlefs.cmake)
include(cmake/Options.cmake)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Buddy
[![GitHub release](https://img.shields.io/github/release/prusa3d/Prusa-Firmware-Buddy.svg)](https://github.com/prusa3d/Prusa-Firmware-Buddy/releases)
[![Build Status](https://holly.prusa3d.com/buildStatus/icon?job=Prusa-Firmware-Buddy%2FMultibranch%2Fmaster)](https://holly.prusa3d.com/job/Prusa-Firmware-Buddy/job/Multibranch/job/master/)
[![Build Status](<https://holly.prusa3d.com/buildStatus/icon?job=Prusa-Firmware-Buddy-Private%2FMultibranch%2Fprivate&subject=private>)](https://holly.prusa3d.com/job/Prusa-Firmware-Buddy-Private/job/Multibranch/job/private/)
[![Build Status](<https://holly.prusa3d.com/buildStatus/icon?job=Prusa-Firmware-Buddy-Private%2FMultibranch%2Fmaster&subject=master>)](https://holly.prusa3d.com/job/Prusa-Firmware-Buddy-Private/job/Multibranch/job/master/)
[![Build Status](<https://holly.prusa3d.com/buildStatus/icon?job=Prusa-Firmware-Buddy-Private%2FAuto-Pull-Master&subject=auto-update-master>)](https://holly.prusa3d.com/job/Prusa-Firmware-Buddy-Private/job/Auto-Pull-Master/)
[![Build Status](<https://holly.prusa3d.com/buildStatus/icon?job=Prusa-Firmware-Buddy-Private%2FMerge-Master-To-Private&subject=merge-master-to-private-daily>)](https://holly.prusa3d.com/job/Prusa-Firmware-Buddy-Private/job/Merge-Master-To-Private/)

This repository includes source code and firmware releases for the Original Prusa 3D printers based on the 32-bit ARM microcontrollers.

The currently supported models are:
- Original Prusa MINI
- Original Prusa MK4
- Original Prusa XL

## Getting Started

Expand Down
47 changes: 47 additions & 0 deletions cmake/CheckRemotes.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
find_package(Git QUIET)

if(NOT GIT_FOUND)
message(STATUS "Not Git Executable found. Skipping check for dangerous Git remotes.")
return()
endif()

function(check_git_repo_for_dangerous_remotes repo_dir)
execute_process(
COMMAND "${GIT_EXECUTABLE}" remote
WORKING_DIRECTORY "${repo_dir}"
RESULT_VARIABLE res
OUTPUT_VARIABLE lst
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT res STREQUAL "0")
message(WARNING "Failed to check dangerousness of your Git remotes!")
return()
endif()

string(REPLACE "\n" ";" lst ${lst})
foreach(item ${lst})
execute_process(
COMMAND "${GIT_EXECUTABLE}" remote get-url --push ${item}
WORKING_DIRECTORY "${repo_dir}"
RESULT_VARIABLE res
OUTPUT_VARIABLE url
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT res STREQUAL 0)
message(WARNING "Failed to check dangerousness of remote '${item}'!")
endif()

if(url MATCHES "Prusa\-Firmware\-Buddy.git" OR url MATCHES "Marlin.git")
message(
FATAL_ERROR
"Oh, your remote '${item}' appears to have its push URL set to a public repository! Let me say, that this is a bad, bad idea! You are \"one push\" away from mistakenly publishing private things. Please remove this remote or set its push url to some nonsense (see below).\n git -C \"${repo_dir}\" remote set-url --push ${item} DISABLED\n"
)
endif()

endforeach()
endfunction()

check_git_repo_for_dangerous_remotes("${CMAKE_SOURCE_DIR}")
check_git_repo_for_dangerous_remotes("${CMAKE_SOURCE_DIR}/lib/Marlin")
7 changes: 4 additions & 3 deletions include/marlin/Configuration_MK4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1438,13 +1438,14 @@

// Homing speeds (mm/m)
#ifdef HAS_LDO_400_STEP
#define HOMING_FEEDRATE_XY (62 * 60)
#include "hw_configuration.hpp"
#define HOMING_FEEDRATE_XY buddy::hw::Configuration::Instance().has_trinamic_oscillators() ? (80 * 60) : (62 * 60)
#else
#define HOMING_FEEDRATE_XY (62 * 60)//(150 * 60)
#define HOMING_FEEDRATE_XY (80 * 60)//(150 * 60)
#endif

#define HOMING_FEEDRATE_Z (8 * 60)
#define HOMING_FEEDRATE_INVERTED_Z (30 * 60)
#define HOMING_FEEDRATE_INVERTED_Z buddy::hw::Configuration::Instance().has_trinamic_oscillators() ? (60 * 60) : (30 * 60)

// Validate that endstops are triggered on homing moves
//#define VALIDATE_HOMING_ENDSTOPS
Expand Down
9 changes: 6 additions & 3 deletions include/marlin/Configuration_MK4_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,8 @@
#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
#if X_DRIVER_TYPE == TMC2130
#if defined(HAS_LDO_400_STEP)
#define X_STALL_SENSITIVITY -2
#include "hw_configuration.hpp"
#define X_STALL_SENSITIVITY buddy::hw::Configuration::Instance().has_trinamic_oscillators() ? (int16_t) -4 : (int16_t) -2
#else
#define X_STALL_SENSITIVITY 3
#endif
Expand All @@ -1817,7 +1818,8 @@

#if Y_DRIVER_TYPE == TMC2130
#if defined(HAS_LDO_400_STEP)
#define Y_STALL_SENSITIVITY -2
#include "hw_configuration.hpp"
#define Y_STALL_SENSITIVITY buddy::hw::Configuration::Instance().has_trinamic_oscillators() ? (int16_t) -4 : (int16_t) -2
#else
#define Y_STALL_SENSITIVITY 3
#endif
Expand All @@ -1826,7 +1828,8 @@
#endif

#if Z_DRIVER_TYPE == TMC2130
#define Z_STALL_SENSITIVITY 3
#include "hw_configuration.hpp"
#define Z_STALL_SENSITIVITY buddy::hw::Configuration::Instance().has_trinamic_oscillators() ? (int16_t) 1 : (int16_t) 3
#elif Z_DRIVER_TYPE == TMC2209
#define Z_STALL_SENSITIVITY 100
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/buddy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ extern "C" void main_cpp(void) {
hw_gpio_init();
hw_dma_init();

// must do this before timer 1
// timer 1 interrupt calls Configuration
#if BOARD_IS_XBUDDY
buddy::hw::Configuration::Instance();
#endif

#if BOARD_IS_BUDDY || BOARD_IS_XBUDDY
hw_tim1_init();
#endif
Expand Down Expand Up @@ -564,6 +558,12 @@ extern "C" void startup_task(void const *) {
init_stores();
taskEXIT_CRITICAL();

// must do this before timer 1, timer 1 interrupt calls Configuration
// also must be before initializing global variables
#if BOARD_IS_XBUDDY
buddy::hw::Configuration::Instance();
#endif

// init global variables and call constructors
extern void __libc_init_array(void);
__libc_init_array();
Expand Down
15 changes: 12 additions & 3 deletions src/common/app_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ void buddy::metrics::RecordRuntimeStats() {

board_revision_t board_revision;
if (otp_get_board_revision(&board_revision) == false) {
board_revision.br = 0;
board_revision = 0;
}
static metric_t buddy_revision = METRIC("buddy_revision", METRIC_VALUE_STRING, 10 * 1002, METRIC_HANDLER_ENABLE_ALL);
metric_record_string(&buddy_revision, "%u.%u", board_revision.bytes[0], board_revision.bytes[1]);

static metric_t buddy_revision = METRIC("buddy_revision", METRIC_VALUE_STRING, 10 * 10002, METRIC_HANDLER_ENABLE_ALL);
metric_record_string(&buddy_revision, "%u", board_revision);

uint8_t bom;
if (otp_get_bom_id(&bom) == false) {
bom = 0;
}

static metric_t buddy_bom = METRIC("buddy_bom", METRIC_VALUE_STRING, 10 * 10003, METRIC_HANDLER_ENABLE_ALL);
metric_record_string(&buddy_bom, "%u", bom);

static metric_t current_filamnet = METRIC("filament", METRIC_VALUE_STRING, 10 * 1007, METRIC_HANDLER_ENABLE_ALL);
auto current_filament = config_store().get_filament_type(marlin_vars()->active_extruder);
Expand Down
4 changes: 3 additions & 1 deletion src/common/bsod_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ void raise_redscreen(ErrCode error_code, const char *error, const char *module)
}
#endif /*_DEBUG*/

#if (!PRINTER_IS_PRUSA_MINI)
// don't trigger redscreen during a power outage
if (power_panic::is_ac_fault_signal()) {
if (error_code != ErrCode::ERR_ELECTRO_ACF_AT_INIT && power_panic::is_ac_fault_signal()) {
delay_ms(2000);
bsod("%s: %s", module, error);
}
#endif

crash_dump::dump_err_to_xflash(static_cast<std::underlying_type_t<ErrCode>>(error_code), error, module);
sys_reset();
Expand Down
18 changes: 9 additions & 9 deletions src/common/hwio_XLBuddy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ static int *const _pwm_period_us[] = {
&_tim1_period_us, //_PWM_FAN
};

// stores board revision from OTP for faster access
board_revision_t board_revision;
// stores board bom ID from OTP for faster access
uint8_t board_bom_id;

// buddy pwm output maximum values
static constexpr int _pwm_max[] = { TIM1_default_Period };
Expand Down Expand Up @@ -629,13 +629,13 @@ void pinMode([[maybe_unused]] uint32_t ulPin, [[maybe_unused]] uint32_t ulMode)
}

void buddy::hw::hwio_configure_board_revision_changed_pins() {
if (!otp_get_board_revision(&board_revision) || board_revision.bytes[0] <= 4) {
bsod("Unable to determine board revision");
if (!otp_get_bom_id(&board_bom_id) || board_bom_id < 4) {
bsod("Unable to determine board BOM ID");
}
log_info(Buddy, "Detected board %d.%d", board_revision.bytes[0], board_revision.bytes[1]);
log_info(Buddy, "Detected bom ID %d", board_bom_id);

// Different HW revisions have different pins connections, figure it out here
if (board_revision.bytes[0] >= 9 || board_revision.bytes[0] == 4) {
if (board_bom_id >= 9 || board_bom_id == 4) {
Buzzer = &pin_a0;
XStep = &pin_d7;
YStep = &pin_d5;
Expand All @@ -645,19 +645,19 @@ void buddy::hw::hwio_configure_board_revision_changed_pins() {
YStep = &pin_a3;
}

if (board_revision.bytes[0] >= 9) {
if (board_bom_id >= 9) {
SideLed_LcdSelector = &pin_e9;
}
}

void hw_init_spi_side_leds() {
// Side leds was connectet to dedicated SPI untill revision 8, in revision 9 SPI is shared with LCD. So init SPI only if needed.
if (board_revision.bytes[0] <= 8) {
if (board_bom_id <= 8) {
hw_spi4_init();
}
}
SPI_HandleTypeDef *hw_get_spi_side_strip() {
if (board_revision.bytes[0] >= 9 || board_revision.bytes[0] == 4) {
if (board_bom_id >= 9 || board_bom_id == 4) {
return &SPI_HANDLE_FOR(lcd);
} else {
return &hspi4;
Expand Down
18 changes: 18 additions & 0 deletions src/common/marlin_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,24 @@ static void _server_print_loop(void) {
case PrintPreview::Result::Inactive:
did_not_start_print = false;
new_state = State::PrintInit;

#if HAS_TOOLCHANGER() && ENABLED(PRUSA_TOOL_MAPPING)
///@todo Remove this when toolmapping screen is done.
/// If the G-code is sliced for singletool, allow printing with currently selected tool.
if (prusa_toolchanger.is_toolchanger_enabled() // Toolchanger available
&& GCodeInfo::getInstance().get_extruder_info(0).used() // Tool 0 is given in comments and used
&& !GCodeInfo::getInstance().get_extruder_info(1).given() // Other tools are not given in comments at all
&& !GCodeInfo::getInstance().get_extruder_info(2).given() // Sliced for multitool: ; filament used [g] = 0.34, 0.00, 0.00, 0.00, 0.00
&& !GCodeInfo::getInstance().get_extruder_info(3).given() // Sliced for singletool: ; filament used [g] = 0.34
&& !GCodeInfo::getInstance().get_extruder_info(4).given()
&& active_extruder > 0 && active_extruder < PrusaToolChanger::MARLIN_NO_TOOL_PICKED) { // User has picked tool 2, 3, 4 or 5

// Map tool 0 to picked tool
tool_mapper.reset();
tool_mapper.set_mapping(0, active_extruder);
tool_mapper.set_enable(true);
}
#endif /*HAS_TOOLCHANGER() && ENABLED(PRUSA_TOOL_MAPPING)*/
break;
}

Expand Down
7 changes: 3 additions & 4 deletions src/common/otp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool otp_parse_board_revision(board_revision_t *revision, const uint8_t *memory,
if (!otp_parse_datamatrix(&datamatrix, memory, len))
return false;

revision->br = datamatrix.revision;
*revision = datamatrix.revision;
return true;
} else if (structure_version <= 2) {
if (len < 2) {
Expand All @@ -143,10 +143,9 @@ bool otp_parse_board_revision(board_revision_t *revision, const uint8_t *memory,
// older OTP layout
const uint8_t *board_revision = memory;
if (board_revision[0] == 0xFF || board_revision[0] == 1) {
return false; // TODO: really? (I don't think so)
return false; // TODO: really? (I don't think so)
} else {
revision->bytes[0] = board_revision[1];
revision->bytes[1] = board_revision[2];
*revision = board_revision[0] * 100 + board_revision[1] * 10 + board_revision[2]; // TODO test MINI
return true;
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/common/otp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ typedef struct {
uint8_t mac[6];
} MAC_addr;

typedef union {
uint16_t br;
uint8_t bytes[2];
} board_revision_t;
typedef uint16_t board_revision_t;

typedef struct {
char txt[25];
Expand Down Expand Up @@ -69,6 +66,9 @@ uint8_t otp_get_serial_nr(serial_nr_t *sn);

/**
* @brief Get BOM ID from OTP.
* BOM == bill of material - list of electronic parts
* some parts might need different fw
* so in case of different hw support it is better to check this than board version
* @param bom_id output BOM ID
* @return true if parsed correctly, false otherwise
*/
Expand Down
2 changes: 1 addition & 1 deletion src/common/selftest/selftest_MK4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static constexpr const char *_suffix[] = { "_fan", "_xyz", "_heaters" };
/// These speeds create major chord
/// https://en.wikipedia.org/wiki/Just_intonation

static constexpr float XYfr_table[] = { HOMING_FEEDRATE_XY / 60 };
static const float XYfr_table[] = { HOMING_FEEDRATE_XY / 60 };
static constexpr size_t xy_fr_table_size = sizeof(XYfr_table) / sizeof(XYfr_table[0]);
static constexpr float Zfr_table_fw[] = { maxFeedrates[Z_AXIS] }; // up
static constexpr float Zfr_table_bw[] = { HOMING_FEEDRATE_Z / 60 };
Expand Down
4 changes: 2 additions & 2 deletions src/gui/version_info_ILI9488.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ ScreenMenuVersionInfo::ScreenMenuVersionInfo()

board_revision_t board_revision;
if (otp_get_board_revision(&board_revision) == false) {
board_revision.br = 0;
board_revision = 0;
}
snprintf(help_str, GuiDefaults::infoDefaultLen, "%d.%d", board_revision.bytes[0], board_revision.bytes[1]);
snprintf(help_str, GuiDefaults::infoDefaultLen, "%d", board_revision);
;
Item<MI_INFO_BOARD>().ChangeInformation(help_str);

Expand Down
6 changes: 3 additions & 3 deletions src/gui/version_info_ST7789V.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ScreenMenuVersionInfo::ScreenMenuVersionInfo()
//=============ACCESS IN ADDR=================
board_revision_t board_revision;
if (otp_get_board_revision(&board_revision) == false) {
board_revision.br = 0;
board_revision = 0;
}

serial_nr_t serial_nr;
Expand Down Expand Up @@ -66,13 +66,13 @@ ScreenMenuVersionInfo::ScreenMenuVersionInfo()

if (end > begin) {
// c=20 r=4
static const char fmt2Translate[] = N_("\nBootloader Version\n%d.%d.%d\n\nBuddy Board\n%d.%d\n%s");
static const char fmt2Translate[] = N_("\nBootloader Version\n%d.%d.%d\n\nBuddy Board\n%d\n%s");
char fmt[20 * 4];
_(fmt2Translate).copyToRAM(fmt, sizeof(fmt)); // note the underscore at the beginning of this line
begin += snprintf(begin, end - begin,
fmt,
bootloader->major, bootloader->minor, bootloader->patch,
board_revision.bytes[0], board_revision.bytes[1],
board_revision,
serial_nr.txt);
}

Expand Down
6 changes: 3 additions & 3 deletions src/hw/mk3.5/hw_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Configuration &Configuration::Instance() {
}

Configuration::Configuration() {
board_revision_t rev;
otp_get_board_revision(&rev);
uint8_t bom_id;
otp_get_bom_id(&bom_id);

if (rev.bytes[0] == 27) {
if (bom_id == 27) {
bsod("Wrong board version");
}
}
Expand Down
1 change: 1 addition & 0 deletions src/hw/mk4_ix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target_include_directories(firmware PRIVATE . include)
target_include_directories(BuddyHeaders INTERFACE .)

target_sources(firmware PRIVATE calibrated_loveboard.cpp hw_configuration.cpp)
Loading

0 comments on commit 10b2c5d

Please sign in to comment.