Skip to content
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

propagate additional process loading errors to main.rs #1770

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 22 additions & 4 deletions kernel/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ pub enum ProcessLoadError {
/// Not enough flash remaining to parse an app and its header.
NotEnoughFlash,

/// Not enough memory to meet the amount requested by an app.
/// Modify your app to request less memory or flash fewer apps or
/// increase the size of the region your board reserves for app memory.
NotEnoughMemory,

/// An app was loaded with a length in flash that the MPU does not support.
/// The fix is probably to correct the app size, but this could also be caused
/// by a bad MPU implementation.
MpuInvalidFlashLength,

/// Process loading error due (likely) to a bug in the kernel. If you get
/// this error please open a bug report.
InternalError,
Expand Down Expand Up @@ -58,6 +68,14 @@ impl fmt::Debug for ProcessLoadError {
write!(f, "Not enough flash available for app linked list")
}

ProcessLoadError::NotEnoughMemory => {
write!(f, "Not able to meet memory requirements requested by apps")
}

ProcessLoadError::MpuInvalidFlashLength => {
write!(f, "App flash length not supported by MPU")
}

ProcessLoadError::InternalError => write!(f, "Error in kernel. Likely a bug."),
}
}
Expand Down Expand Up @@ -1595,13 +1613,13 @@ impl<C: 'static + Chip> Process<'a, C> {
{
if config::CONFIG.debug_load_processes {
debug!(
"[!] flash=[{:#010X}:{:#010X}] process={:?} - couldn't allocate flash region",
"[!] flash=[{:#010X}:{:#010X}] process={:?} - couldn't allocate MPU region for flash",
app_flash.as_ptr() as usize,
app_flash.as_ptr() as usize + app_flash.len(),
process_name
);
}
return Ok((None, 0));
return Err(ProcessLoadError::MpuInvalidFlashLength);
}

// Determine how much space we need in the application's
Expand Down Expand Up @@ -1656,7 +1674,7 @@ impl<C: 'static + Chip> Process<'a, C> {
min_total_memory_size
);
}
return Ok((None, 0));
return Err(ProcessLoadError::NotEnoughMemory);
}
};

Expand Down Expand Up @@ -1793,7 +1811,7 @@ impl<C: 'static + Chip> Process<'a, C> {
process_name
);
}
return Ok((None, 0));
return Err(ProcessLoadError::InternalError);
}
};

Expand Down